-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAMD64Ops.cpp
87 lines (73 loc) · 2.75 KB
/
AMD64Ops.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "AMD64/AMD64Ops.h"
#include "AMD64/AMD64Dialect.h"
#include "mlir/IR/OpImplementation.h"
#include <concepts>
#include <cstdint>
#include <err.h>
#include <mlir/Support/LogicalResult.h>
using mlir::success;
using mlir::failure;
using mlir::failed;
#include "mlir/IR/OperationSupport.h"
// either include ODSSupport.h (which doesn't have all of the required convertToAttribute/convertFromAttribute methods for properties)
//#include "mlir/IR/ODSSupport.h"
// or define them yourself:
template<std::signed_integral T>
mlir::LogicalResult convertFromAttribute(T &storage,
::mlir::Attribute attr,
::mlir::InFlightDiagnostic *diag) {
auto valueAttr = dyn_cast<mlir::IntegerAttr>(attr);
if (!valueAttr) {
if (diag)
*diag << "expected IntegerAttr for key `value`";
return failure();
}
storage = valueAttr.getValue().getSExtValue();
return success();
}
template<std::unsigned_integral T>
mlir::LogicalResult convertFromAttribute(T &storage,
::mlir::Attribute attr,
::mlir::InFlightDiagnostic *diag) {
auto valueAttr = dyn_cast<mlir::IntegerAttr>(attr);
if (!valueAttr) {
if (diag)
*diag << "expected IntegerAttr for key `value`";
return failure();
}
storage = valueAttr.getValue().getZExtValue();
return success();
}
template<std::integral T>
mlir::Attribute convertToAttribute(mlir::MLIRContext* ctx, T storage) {
return mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, sizeof(T)*8), storage);
}
template<typename T>
mlir::LogicalResult readFromMlirBytecode(mlir::DialectBytecodeReader&, T&) {
errx(EXIT_FAILURE, "Conversion to/from bytecode not implemented");
return mlir::failure();
}
template<typename T>
void writeToMlirBytecode(::mlir::DialectBytecodeWriter&, T&) {
errx(EXIT_FAILURE, "Conversion to/from bytecode not implemented");
}
template<typename T>
mlir::Attribute convertToAttribute(mlir::MLIRContext* ctx, T){
errx(EXIT_FAILURE, "Conversion to/from attribute not implemented");
return mlir::UnitAttr::get(ctx);
}
template<typename T>
mlir::LogicalResult convertFromAttribute(T&, ::mlir::Attribute, ::mlir::InFlightDiagnostic*){
errx(EXIT_FAILURE, "Conversion to/from attribute not implemented");
return mlir::failure();
}
// someone didn't qualify their types in mlir-tblgen between 583d492c6 (where this wasn't necessary) and a403d75be7 (where it is)
using namespace llvm;
using namespace mlir;
//template<typename T>
//using ArrayRef = llvm::ArrayRef<T>;
#define GET_OP_CLASSES
#include "AMD64/AMD64Ops.cpp.inc"
#include "AMD64/AMD64OpsEnums.cpp.inc"
#include "AMD64/AMD64OpInterfaces.cpp.inc"
#include "AMD64/AMD64TypeInterfaces.cpp.inc"