blob: d835c4076224ad7bb43979125b7bd8e2214cedc3 [file] [log] [blame]
#include "clang/CIR/Dialect/IR/CIRDataLayout.h"
using namespace cir;
//===----------------------------------------------------------------------===//
// DataLayout Class Implementation
//===----------------------------------------------------------------------===//
CIRDataLayout::CIRDataLayout(mlir::ModuleOp modOp) : layout(modOp) {
reset(modOp.getDataLayoutSpec());
}
void CIRDataLayout::reset(mlir::DataLayoutSpecInterface spec) {
bigEndian = false;
if (spec) {
mlir::StringAttr key = mlir::StringAttr::get(
spec.getContext(), mlir::DLTIDialect::kDataLayoutEndiannessKey);
if (mlir::DataLayoutEntryInterface entry = spec.getSpecForIdentifier(key))
if (auto str = llvm::dyn_cast<mlir::StringAttr>(entry.getValue()))
bigEndian = str == mlir::DLTIDialect::kDataLayoutEndiannessBig;
}
}