jak-project/goalc/regalloc/IRegister.cpp
water111 a80b331c27
[Compiler] In-progress support for vector float (AVX) (#171)
* begin work on vf support

* split reg kind into reg hw kind and class, use class for ireg

* try test

* clang format

* add some more ops and some example functions

* better lvf on statics

* add documentation
2020-12-30 15:33:51 -05:00

34 lines
1.1 KiB
C++

#include <cassert>
#include "third-party/fmt/core.h"
#include "IRegister.h"
std::string IRegister::to_string() const {
// if (with_constraints) {
// std::string result = fmt::format("i{}-{}\n", emitter::to_string(kind), id);
// for (const auto& x : constraints) {
// result += fmt::format(" [{:3d] in {}\n", x.instr_idx,
// emitter::gRegInfo.get_info(x.desired_register).name);
// }
// return result;
// } else {
switch (reg_class) {
case RegClass::GPR_64:
return fmt::format("igpr-{}", id);
case RegClass::FLOAT:
return fmt::format("ifpr-{}", id);
case RegClass::INT_128:
return fmt::format("ii128-{}", id);
case RegClass::VECTOR_FLOAT:
return fmt::format("ivf-{}", id);
default:
assert(false);
}
}
std::string IRegConstraint::to_string() const {
if (contrain_everywhere) {
return fmt::format("[all] {} in {}", ireg.to_string(), desired_register.print());
} else {
return fmt::format("[{:3d}] {} in {}", instr_idx, ireg.to_string(), desired_register.print());
}
}