Skip to content

Commit d526967

Browse files
committed
Revert "[CIR] Upstream basic alloca and load support (llvm#128792)"
This reverts commit 3989b78.
1 parent a3ac1f2 commit d526967

File tree

18 files changed

+1
-945
lines changed

18 files changed

+1
-945
lines changed

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

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
1010
#define LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
1111

12-
#include "clang/AST/CharUnits.h"
1312
#include "clang/CIR/Dialect/IR/CIRAttrs.h"
1413
#include "clang/CIR/Dialect/IR/CIRDialect.h"
1514
#include "clang/CIR/Dialect/IR/CIRTypes.h"
@@ -52,47 +51,6 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
5251
return cir::ConstPtrAttr::get(
5352
getContext(), mlir::cast<cir::PointerType>(type), valueAttr);
5453
}
55-
56-
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType,
57-
mlir::Type type, llvm::StringRef name,
58-
mlir::IntegerAttr alignment) {
59-
return create<cir::AllocaOp>(loc, addrType, type, name, alignment);
60-
}
61-
62-
cir::LoadOp createLoad(mlir::Location loc, mlir::Value ptr,
63-
bool isVolatile = false, uint64_t alignment = 0) {
64-
mlir::IntegerAttr intAttr;
65-
if (alignment)
66-
intAttr = mlir::IntegerAttr::get(
67-
mlir::IntegerType::get(ptr.getContext(), 64), alignment);
68-
69-
return create<cir::LoadOp>(loc, ptr);
70-
}
71-
72-
//
73-
// Block handling helpers
74-
// ----------------------
75-
//
76-
static OpBuilder::InsertPoint getBestAllocaInsertPoint(mlir::Block *block) {
77-
auto last =
78-
std::find_if(block->rbegin(), block->rend(), [](mlir::Operation &op) {
79-
// TODO: Add LabelOp missing feature here
80-
return mlir::isa<cir::AllocaOp>(&op);
81-
});
82-
83-
if (last != block->rend())
84-
return OpBuilder::InsertPoint(block, ++mlir::Block::iterator(&*last));
85-
return OpBuilder::InsertPoint(block, block->begin());
86-
};
87-
88-
mlir::IntegerAttr getSizeFromCharUnits(mlir::MLIRContext *ctx,
89-
clang::CharUnits size) {
90-
// Note that mlir::IntegerType is used instead of cir::IntType here
91-
// because we don't need sign information for this to be useful, so keep
92-
// it simple.
93-
return mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 64),
94-
size.getQuantity());
95-
}
9654
};
9755

9856
} // namespace cir

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,6 @@ def CIR_BoolAttr : CIR_Attr<"Bool", "bool", [TypedAttrInterface]> {
5454
}];
5555
}
5656

57-
//===----------------------------------------------------------------------===//
58-
// UndefAttr
59-
//===----------------------------------------------------------------------===//
60-
61-
def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> {
62-
let summary = "Represent an undef constant";
63-
let description = [{
64-
The UndefAttr represents an undef constant, corresponding to LLVM's notion
65-
of undef.
66-
}];
67-
68-
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
69-
let assemblyFormat = [{}];
70-
}
71-
7257
//===----------------------------------------------------------------------===//
7358
// IntegerAttr
7459
//===----------------------------------------------------------------------===//

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

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -115,119 +115,6 @@ def ConstantOp : CIR_Op<"const",
115115
let hasFolder = 1;
116116
}
117117

118-
//===----------------------------------------------------------------------===//
119-
// AllocaOp
120-
//===----------------------------------------------------------------------===//
121-
122-
class AllocaTypesMatchWith<string summary, string lhsArg, string rhsArg,
123-
string transform, string comparator = "std::equal_to<>()">
124-
: PredOpTrait<summary, CPred<
125-
comparator # "(" #
126-
!subst("$_self", "$" # lhsArg # ".getType()", transform) #
127-
", $" # rhsArg # ")">> {
128-
string lhs = lhsArg;
129-
string rhs = rhsArg;
130-
string transformer = transform;
131-
}
132-
133-
def AllocaOp : CIR_Op<"alloca", [
134-
AllocaTypesMatchWith<"'allocaType' matches pointee type of 'addr'",
135-
"addr", "allocaType",
136-
"cast<PointerType>($_self).getPointee()">,
137-
DeclareOpInterfaceMethods<PromotableAllocationOpInterface>]> {
138-
let summary = "Defines a scope-local variable";
139-
let description = [{
140-
The `cir.alloca` operation defines a scope-local variable.
141-
142-
The presence of the `const` attribute indicates that the local variable is
143-
declared with C/C++ `const` keyword.
144-
145-
The result type is a pointer to the input's type.
146-
147-
Example:
148-
149-
```mlir
150-
// int count;
151-
%0 = cir.alloca i32, !cir.ptr<i32>, ["count"] {alignment = 4 : i64}
152-
153-
// int *ptr;
154-
%1 = cir.alloca !cir.ptr<i32>, !cir.ptr<!cir.ptr<i32>>, ["ptr"] {alignment = 8 : i64}
155-
...
156-
```
157-
}];
158-
159-
let arguments = (ins
160-
TypeAttr:$allocaType,
161-
StrAttr:$name,
162-
UnitAttr:$init,
163-
UnitAttr:$constant,
164-
ConfinedAttr<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$alignment,
165-
OptionalAttr<ArrayAttr>:$annotations
166-
);
167-
168-
let results = (outs Res<CIR_PointerType, "",
169-
[MemAlloc<AutomaticAllocationScopeResource>]>:$addr);
170-
171-
let skipDefaultBuilders = 1;
172-
let builders = [
173-
OpBuilder<(ins "mlir::Type":$addr,
174-
"mlir::Type":$allocaType,
175-
"llvm::StringRef":$name,
176-
"mlir::IntegerAttr":$alignment)>
177-
];
178-
179-
let extraClassDeclaration = [{
180-
// Whether the alloca input type is a pointer.
181-
bool isPointerType() { return ::mlir::isa<::cir::PointerType>(getAllocaType()); }
182-
}];
183-
184-
let assemblyFormat = [{
185-
$allocaType `,` qualified(type($addr)) `,`
186-
`[` $name
187-
(`,` `init` $init^)?
188-
(`,` `const` $constant^)?
189-
`]`
190-
($annotations^)? attr-dict
191-
}];
192-
193-
let hasVerifier = 0;
194-
}
195-
196-
//===----------------------------------------------------------------------===//
197-
// LoadOp
198-
//===----------------------------------------------------------------------===//
199-
200-
def LoadOp : CIR_Op<"load", [
201-
TypesMatchWith<"type of 'result' matches pointee type of 'addr'",
202-
"addr", "result",
203-
"cast<PointerType>($_self).getPointee()">,
204-
DeclareOpInterfaceMethods<PromotableMemOpInterface>]> {
205-
206-
let summary = "Load value from memory adddress";
207-
let description = [{
208-
`cir.load` reads a value (lvalue to rvalue conversion) given an address
209-
backed up by a `cir.ptr` type.
210-
211-
Example:
212-
213-
```mlir
214-
215-
// Read from local variable, address in %0.
216-
%1 = cir.load %0 : !cir.ptr<i32>, i32
217-
```
218-
}];
219-
220-
let arguments = (ins Arg<CIR_PointerType, "the address to load from",
221-
[MemRead]>:$addr);
222-
let results = (outs CIR_AnyType:$result);
223-
224-
let assemblyFormat = [{
225-
$addr `:` qualified(type($addr)) `,` type($result) attr-dict
226-
}];
227-
228-
// FIXME: add verifier.
229-
}
230-
231118
//===----------------------------------------------------------------------===//
232119
// ReturnOp
233120
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,12 @@ struct MissingFeatures {
3030
// This isn't needed until we add support for bools.
3131
static bool convertTypeForMemory() { return false; }
3232

33-
// CIRGenFunction implementation details
34-
static bool cgfSymbolTable() { return false; }
35-
3633
// Unhandled global/linkage information.
3734
static bool opGlobalDSOLocal() { return false; }
3835
static bool opGlobalThreadLocal() { return false; }
3936
static bool opGlobalConstant() { return false; }
4037
static bool opGlobalAlignment() { return false; }
4138
static bool opGlobalLinkage() { return false; }
42-
43-
// Load attributes
44-
static bool opLoadThreadLocal() { return false; }
45-
static bool opLoadEmitScalarRangeCheck() { return false; }
46-
static bool opLoadBooleanRepresentation() { return false; }
47-
48-
// AllocaOp handling
49-
static bool opAllocaVarDeclContext() { return false; }
50-
static bool opAllocaStaticLocal() { return false; }
51-
static bool opAllocaNonGC() { return false; }
52-
static bool opAllocaImpreciseLifetime() { return false; }
53-
static bool opAllocaPreciseLifetime() { return false; }
54-
static bool opAllocaTLS() { return false; }
55-
static bool opAllocaOpenMPThreadPrivate() { return false; }
56-
static bool opAllocaEscapeByReference() { return false; }
57-
static bool opAllocaReference() { return false; }
58-
59-
// Misc
60-
static bool scalarConversionOpts() { return false; }
61-
static bool tryEmitAsConstant() { return false; }
6239
};
6340

6441
} // namespace cir

clang/lib/CIR/CodeGen/Address.h

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)