| 1 | #include "clang/CIR/Dialect/IR/CIRDataLayout.h" |
| 2 | |
| 3 | using namespace cir; |
| 4 | |
| 5 | //===----------------------------------------------------------------------===// |
| 6 | // DataLayout Class Implementation |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | CIRDataLayout::CIRDataLayout(mlir::ModuleOp modOp) : layout(modOp) { |
| 10 | reset(modOp.getDataLayoutSpec()); |
| 11 | } |
| 12 | |
| 13 | void CIRDataLayout::reset(mlir::DataLayoutSpecInterface spec) { |
| 14 | bigEndian = false; |
| 15 | if (spec) { |
| 16 | mlir::StringAttr key = mlir::StringAttr::get( |
| 17 | spec.getContext(), mlir::DLTIDialect::kDataLayoutEndiannessKey); |
| 18 | if (mlir::DataLayoutEntryInterface entry = spec.getSpecForIdentifier(key)) |
| 19 | if (auto str = llvm::dyn_cast<mlir::StringAttr>(entry.getValue())) |
| 20 | bigEndian = str == mlir::DLTIDialect::kDataLayoutEndiannessBig; |
| 21 | } |
| 22 | } |
| 23 | |