-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR][CIRDataLayout]moving CIRDataLayout to MLIRCIR (#693)
fix build failure undefined reference to `cir::CIRDataLayout::CIRDataLayout(mlir::ModuleOp)' by breaking circular dependency caused by the fact CIRDataLayout was in CIR Codegen
- Loading branch information
Showing
3 changed files
with
44 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//===- CIRDialect.cpp - MLIR CIR ops implementation -----------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file defines the CIR DataLayout class and its functions. | ||
// | ||
//===----------------------------------------------------------------------===//a | ||
// | ||
|
||
#include "clang/CIR/Dialect/IR/CIRDataLayout.h" | ||
|
||
namespace cir { | ||
CIRDataLayout::CIRDataLayout(mlir::ModuleOp modOp) : layout{modOp} { | ||
auto dlSpec = modOp->getAttr(mlir::DLTIDialect::kDataLayoutAttrName) | ||
.dyn_cast<mlir::DataLayoutSpecAttr>(); | ||
assert(dlSpec && "expected dl_spec in the module"); | ||
auto entries = dlSpec.getEntries(); | ||
|
||
for (auto entry : entries) { | ||
auto entryKey = entry.getKey(); | ||
auto strKey = entryKey.dyn_cast<mlir::StringAttr>(); | ||
if (!strKey) | ||
continue; | ||
auto entryName = strKey.strref(); | ||
if (entryName == mlir::DLTIDialect::kDataLayoutEndiannessKey) { | ||
auto value = entry.getValue().dyn_cast<mlir::StringAttr>(); | ||
assert(value && "expected string attribute"); | ||
auto endian = value.getValue(); | ||
if (endian == mlir::DLTIDialect::kDataLayoutEndiannessBig) | ||
bigEndian = true; | ||
else if (endian == mlir::DLTIDialect::kDataLayoutEndiannessLittle) | ||
bigEndian = false; | ||
else | ||
llvm_unreachable("unknown endianess"); | ||
} | ||
} | ||
} | ||
|
||
} // namespace cir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
add_clang_library(MLIRCIR | ||
CIRAttrs.cpp | ||
CIRDataLayout.cpp | ||
CIRDialect.cpp | ||
CIRTypes.cpp | ||
FPEnv.cpp | ||
|