Skip to content

Commit c73a060

Browse files
committed
Revert "[CIR] Upstream type bool (llvm#128601)"
This reverts commit eacbcbe.
1 parent 8571d40 commit c73a060

File tree

10 files changed

+2
-122
lines changed

10 files changed

+2
-122
lines changed

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#define LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
1111

1212
#include "clang/CIR/Dialect/IR/CIRAttrs.h"
13-
#include "clang/CIR/Dialect/IR/CIRDialect.h"
14-
#include "clang/CIR/Dialect/IR/CIRTypes.h"
1513

1614
#include "mlir/IR/Builders.h"
1715
#include "mlir/IR/BuiltinTypes.h"
@@ -25,14 +23,6 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
2523
CIRBaseBuilderTy(mlir::MLIRContext &mlirContext)
2624
: mlir::OpBuilder(&mlirContext) {}
2725

28-
cir::ConstantOp getBool(bool state, mlir::Location loc) {
29-
return create<cir::ConstantOp>(loc, getBoolTy(), getCIRBoolAttr(state));
30-
}
31-
cir::ConstantOp getFalse(mlir::Location loc) { return getBool(false, loc); }
32-
cir::ConstantOp getTrue(mlir::Location loc) { return getBool(true, loc); }
33-
34-
cir::BoolType getBoolTy() { return cir::BoolType::get(getContext()); }
35-
3626
cir::PointerType getPointerTo(mlir::Type ty) {
3727
return cir::PointerType::get(getContext(), ty);
3828
}
@@ -41,10 +31,6 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
4131
return getPointerTo(cir::VoidType::get(getContext()));
4232
}
4333

44-
cir::BoolAttr getCIRBoolAttr(bool state) {
45-
return cir::BoolAttr::get(getContext(), getBoolTy(), state);
46-
}
47-
4834
mlir::TypedAttr getConstPtrAttr(mlir::Type type, int64_t value) {
4935
auto valueAttr = mlir::IntegerAttr::get(
5036
mlir::IntegerType::get(type.getContext(), 64), value);

clang/include/clang/CIR/Dialect/IR/CIRAttrs.td

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,6 @@ class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
3535
let isOptional = 1;
3636
}
3737

38-
//===----------------------------------------------------------------------===//
39-
// BoolAttr
40-
//===----------------------------------------------------------------------===//
41-
42-
def CIR_BoolAttr : CIR_Attr<"Bool", "bool", [TypedAttrInterface]> {
43-
let summary = "Represent true/false for !cir.bool types";
44-
let description = [{
45-
The BoolAttr represents a 'true' or 'false' value.
46-
}];
47-
48-
let parameters = (ins AttributeSelfTypeParameter<
49-
"", "cir::BoolType">:$type,
50-
"bool":$value);
51-
52-
let assemblyFormat = [{
53-
`<` $value `>`
54-
}];
55-
}
56-
5738
//===----------------------------------------------------------------------===//
5839
// IntegerAttr
5940
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/Dialect/IR/CIRTypes.td

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,6 @@ def CIR_PointerType : CIR_Type<"Pointer", "ptr",
266266
}];
267267
}
268268

269-
//===----------------------------------------------------------------------===//
270-
// BoolType
271-
//===----------------------------------------------------------------------===//
272-
273-
def CIR_BoolType :
274-
CIR_Type<"Bool", "bool",
275-
[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
276-
277-
let summary = "CIR bool type";
278-
let description = [{
279-
`cir.bool` represents C++ bool type.
280-
}];
281-
}
282-
283269
//===----------------------------------------------------------------------===//
284270
// FuncType
285271
//===----------------------------------------------------------------------===//
@@ -369,8 +355,7 @@ def VoidPtr : Type<
369355
//===----------------------------------------------------------------------===//
370356

371357
def CIR_AnyType : AnyTypeOf<[
372-
CIR_VoidType, CIR_BoolType, CIR_IntType, CIR_AnyFloat, CIR_PointerType,
373-
CIR_FuncType
358+
CIR_VoidType, CIR_IntType, CIR_AnyFloat, CIR_PointerType, CIR_FuncType
374359
]>;
375360

376361
#endif // MLIR_CIR_DIALECT_CIR_TYPES

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
5858
cgf.getLoc(e->getExprLoc()), type,
5959
builder.getAttr<cir::IntAttr>(type, e->getValue()));
6060
}
61-
62-
mlir::Value VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *e) {
63-
mlir::Type type = cgf.convertType(e->getType());
64-
return builder.create<cir::ConstantOp>(
65-
cgf.getLoc(e->getExprLoc()), type,
66-
builder.getCIRBoolAttr(e->getValue()));
67-
}
6861
};
6962
} // namespace
7063

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,7 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
141141
if (APValue *value = initDecl->evaluateValue()) {
142142
switch (value->getKind()) {
143143
case APValue::Int: {
144-
if (mlir::isa<cir::BoolType>(type))
145-
initializer =
146-
builder.getCIRBoolAttr(value->getInt().getZExtValue());
147-
else
148-
initializer = builder.getAttr<cir::IntAttr>(type, value->getInt());
144+
initializer = builder.getAttr<cir::IntAttr>(type, value->getInt());
149145
break;
150146
}
151147
case APValue::Float: {

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
108108
resultType = cgm.VoidTy;
109109
break;
110110

111-
// bool
112-
case BuiltinType::Bool:
113-
resultType = cir::BoolType::get(&getMLIRContext());
114-
break;
115-
116111
// Signed integral types.
117112
case BuiltinType::Char_S:
118113
case BuiltinType::Int:

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,6 @@ using namespace cir;
2525
//===----------------------------------------------------------------------===//
2626
// CIR Dialect
2727
//===----------------------------------------------------------------------===//
28-
namespace {
29-
struct CIROpAsmDialectInterface : public OpAsmDialectInterface {
30-
using OpAsmDialectInterface::OpAsmDialectInterface;
31-
32-
AliasResult getAlias(Type type, raw_ostream &os) const final {
33-
return AliasResult::NoAlias;
34-
}
35-
36-
AliasResult getAlias(Attribute attr, raw_ostream &os) const final {
37-
if (auto boolAttr = mlir::dyn_cast<cir::BoolAttr>(attr)) {
38-
os << (boolAttr.getValue() ? "true" : "false");
39-
return AliasResult::FinalAlias;
40-
}
41-
return AliasResult::NoAlias;
42-
}
43-
};
44-
} // namespace
4528

4629
void cir::CIRDialect::initialize() {
4730
registerTypes();
@@ -50,7 +33,6 @@ void cir::CIRDialect::initialize() {
5033
#define GET_OP_LIST
5134
#include "clang/CIR/Dialect/IR/CIROps.cpp.inc"
5235
>();
53-
addInterfaces<CIROpAsmDialectInterface>();
5436
}
5537

5638
//===----------------------------------------------------------------------===//
@@ -130,13 +112,6 @@ static LogicalResult checkConstantTypes(mlir::Operation *op, mlir::Type opType,
130112
return success();
131113
}
132114

133-
if (mlir::isa<cir::BoolAttr>(attrType)) {
134-
if (!mlir::isa<cir::BoolType>(opType))
135-
return op->emitOpError("result type (")
136-
<< opType << ") must be '!cir.bool' for '" << attrType << "'";
137-
return success();
138-
}
139-
140115
if (mlir::isa<cir::IntAttr, cir::FPAttr>(attrType)) {
141116
auto at = cast<TypedAttr>(attrType);
142117
if (at.getType() != opType) {

clang/lib/CIR/Dialect/IR/CIRTypes.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -381,28 +381,6 @@ llvm::ArrayRef<mlir::Type> FuncType::getReturnTypes() const {
381381

382382
bool FuncType::isVoid() const { return mlir::isa<VoidType>(getReturnType()); }
383383

384-
//===----------------------------------------------------------------------===//
385-
// BoolType
386-
//===----------------------------------------------------------------------===//
387-
388-
llvm::TypeSize
389-
BoolType::getTypeSizeInBits(const ::mlir::DataLayout &dataLayout,
390-
::mlir::DataLayoutEntryListRef params) const {
391-
return llvm::TypeSize::getFixed(8);
392-
}
393-
394-
uint64_t
395-
BoolType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
396-
::mlir::DataLayoutEntryListRef params) const {
397-
return 1;
398-
}
399-
400-
uint64_t
401-
BoolType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
402-
::mlir::DataLayoutEntryListRef params) const {
403-
return 1;
404-
}
405-
406384
//===----------------------------------------------------------------------===//
407385
// PointerType Definitions
408386
//===----------------------------------------------------------------------===//

clang/test/CIR/func-simple.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,3 @@ unsigned long long ullfunc() { return 42ull; }
5151
// CHECK: %0 = cir.const #cir.int<42> : !cir.int<u, 64>
5252
// CHECK: cir.return %0 : !cir.int<u, 64>
5353
// CHECK: }
54-
55-
bool boolfunc() { return true; }
56-
// CHECK: cir.func @boolfunc() -> !cir.bool {
57-
// CHECK: %0 = cir.const #true
58-
// CHECK: cir.return %0 : !cir.bool
59-
// CHECK: }

clang/test/CIR/global-var-simple.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ _BitInt(20) sb20;
5858
unsigned _BitInt(48) ub48;
5959
// CHECK: cir.global @ub48 : !cir.int<u, 48>
6060

61-
bool boolfalse = false;
62-
// CHECK: cir.global @boolfalse = #false
63-
6461
_Float16 f16;
6562
// CHECK: cir.global @f16 : !cir.f16
6663

0 commit comments

Comments
 (0)