16#include "mlir/IR/Builders.h"
17#include "mlir/IR/DialectImplementation.h"
18#include "llvm/ADT/TypeSwitch.h"
27#define GET_TYPEDEF_CLASSES
28#include "circt/Dialect/RTGTest/IR/RTGTestTypes.cpp.inc"
34bool IntegerRegisterType::isValidContentType(Type type)
const {
35 return llvm::isa<IntegerType>(type);
38TypedAttr IntegerRegisterType::parseContentValue(llvm::StringRef valueString,
39 Type contentType)
const {
40 auto immType = dyn_cast<IntegerType>(contentType);
45 if (valueString.getAsInteger(0, intValue))
48 if (intValue.getBitWidth() < immType.getWidth()) {
49 intValue = intValue.zext(immType.getWidth());
51 if (!intValue.isIntN(immType.getWidth()))
53 intValue = intValue.trunc(immType.getWidth());
56 return IntegerAttr::get(
57 IntegerType::get(getContext(), intValue.getBitWidth()), intValue);
60std::string IntegerRegisterType::getIntrinsicLabel(Attribute value,
61 llvm::StringRef
id)
const {
62 return "spike.pre.printreg.x" +
64 cast<rtg::RegisterAttrInterface>(value).getClassIndex()) +
68unsigned IntegerRegisterType::getRegisterClassSize() {
return 32; }
70rtg::RegisterAttrInterface
71IntegerRegisterType::getRegisterAttrForClassIndex(MLIRContext *ctx,
75 return RegZeroAttr::get(ctx);
77 return RegRaAttr::get(ctx);
79 return RegSpAttr::get(ctx);
81 return RegGpAttr::get(ctx);
83 return RegTpAttr::get(ctx);
85 return RegT0Attr::get(ctx);
87 return RegT1Attr::get(ctx);
89 return RegT2Attr::get(ctx);
91 return RegS0Attr::get(ctx);
93 return RegS1Attr::get(ctx);
95 return RegA0Attr::get(ctx);
97 return RegA1Attr::get(ctx);
99 return RegA2Attr::get(ctx);
101 return RegA3Attr::get(ctx);
103 return RegA4Attr::get(ctx);
105 return RegA5Attr::get(ctx);
107 return RegA6Attr::get(ctx);
109 return RegA7Attr::get(ctx);
111 return RegS2Attr::get(ctx);
113 return RegS3Attr::get(ctx);
115 return RegS4Attr::get(ctx);
117 return RegS5Attr::get(ctx);
119 return RegS6Attr::get(ctx);
121 return RegS7Attr::get(ctx);
123 return RegS8Attr::get(ctx);
125 return RegS9Attr::get(ctx);
127 return RegS10Attr::get(ctx);
129 return RegS11Attr::get(ctx);
131 return RegT3Attr::get(ctx);
133 return RegT4Attr::get(ctx);
135 return RegT5Attr::get(ctx);
137 return RegT6Attr::get(ctx);
146unsigned FloatRegisterType::getRegisterClassSize() {
return 1; }
148rtg::RegisterAttrInterface
149FloatRegisterType::getRegisterAttrForClassIndex(MLIRContext *ctx,
153 return RegF0Attr::get(ctx);
163void circt::rtgtest::RTGTestDialect::registerTypes() {
165#define GET_TYPEDEF_LIST
166#include "circt/Dialect/RTGTest/IR/RTGTestTypes.cpp.inc"
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.