Skip to content

Commit 16688e9

Browse files
committed
[Heavy] Update to Clang22
1 parent f389848 commit 16688e9

File tree

14 files changed

+55
-64
lines changed

14 files changed

+55
-64
lines changed

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
LANGOPT(Name, Bits, Default, Compatibility, Description)
3838
#endif
3939

40-
<<<<<<< HEAD
4140
// FIXME: A lot of the Benign options should be Compatible instead.
4241
LANGOPT(C99 , 1, 0, NotCompatible, "C99")
4342
LANGOPT(C11 , 1, 0, NotCompatible, "C11")
@@ -88,7 +87,7 @@ LANGOPT(AppleKext , 1, 0, NotCompatible, "Apple kext support")
8887
LANGOPT(PascalStrings , 1, 0, Benign, "Pascal string support")
8988
LANGOPT(WritableStrings , 1, 0, NotCompatible, "writable string support")
9089
LANGOPT(ConstStrings , 1, 0, NotCompatible, "const-qualified string support")
91-
LANGOPT(Heavy , 1, 0, "Heavy")
90+
LANGOPT(Heavy , 1, 0, NotCompatible, "Heavy scheme integration")
9291
ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
9392
LaxVectorConversionKind::All, NotCompatible, "lax vector conversions")
9493
ENUM_LANGOPT(AltivecSrcCompat, AltivecSrcCompatKind, 2,

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7051,7 +7051,7 @@ class Parser : public CodeCompletionHandler {
70517051
std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
70527052
std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
70537053
std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
7054-
std::unique_ptr<heavy::Context> HeavySchemeContext;
7054+
std::unique_ptr<heavy::HeavyScheme> HeavyScheme;
70557055

70567056
/// Initialize all pragma handlers.
70577057
void initializePragmaHandlers();

clang/lib/Lex/Preprocessor.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,17 +1716,6 @@ void NoTrivialPPDirectiveTracer::MacroExpands(const Token &MacroNameTok,
17161716
setSeenNoTrivialPPDirective();
17171717
}
17181718

1719-
void Preprocessor::InitHeavySchemeLexer() {
1720-
if (!TheHeavySchemeLexer) {
1721-
TheHeavySchemeLexer = std::unique_ptr<HeavySchemeLexer>(
1722-
new HeavySchemeLexer(*this));
1723-
}
1724-
TheHeavySchemeLexer->Init(CurLexer->getFileLoc(),
1725-
CurLexer->BufferStart,
1726-
CurLexer->BufferEnd,
1727-
CurLexer->BufferPtr);
1728-
}
1729-
17301719
void Preprocessor::InitEmbeddedLexer(
17311720
llvm::function_ref<EmbeddedLexerInitFn> InitFn) {
17321721
assert(IsFileLexer() && "cannot embed scheme in macro expansion");

heavy/include/heavy/ContinuationStack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class ContinuationStack {
165165
if (Src.getDepth() < Dest.getDepth()) {
166166
C.PushCont([](Derived& C, ValueRefs) {
167167
DWind Dest = C.getCapture(0);
168-
C.Apply(Dest.getBeforeFn(), std::nullopt);
168+
C.ApplyThunk(Value(Dest.getBeforeFn()));
169169
}, CaptureList{Dest});
170170
C.TraverseWindings(Src, Dest.getParent());
171171
} else {
@@ -174,7 +174,7 @@ class ContinuationStack {
174174
DWind Dest = C.getCapture(1);
175175
C.TraverseWindings(Src.getParent(), Dest);
176176
}, CaptureList{Src, Dest});
177-
C.Apply(Src.getAfterFn(), std::nullopt);
177+
C.ApplyThunk(Value(Src.getAfterFn()));
178178
}
179179
}
180180

heavy/include/heavy/OpGen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class OpGen : public ValueVisitor<OpGen, mlir::Value> {
243243
"Operation must have insertion point");
244244
mlir::Location MLoc = mlir::OpaqueLoc::get(Loc.getOpaqueEncoding(),
245245
Builder.getContext());
246-
return Builder.create<Op>(MLoc, std::forward<Args>(args)...);
246+
return Op::create(Builder, MLoc, std::forward<Args>(args)...);
247247
}
248248

249249
template <typename Op, typename ...Args>

heavy/include/heavy/Ops.td

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def heavy_ExpandPacksOp : HeavyOp<"expand_packs", []> {
156156
let builders = [
157157
OpBuilder<(ins "::mlir::Value":$cdr,
158158
"::mlir::ValueRange":$packs,
159-
"std::unique_ptr<::mlir::Region>":$body)>
159+
"std::unique_ptr<::mlir::Region>&&":$body)>
160160
];
161161
}
162162

@@ -370,10 +370,6 @@ def heavy_MatchIdOp : HeavyOp<"match-id", []> {
370370

371371
let arguments = (ins HeavyValue:$val, HeavyValue:$input);
372372
let results = (outs);
373-
374-
let builders = [
375-
OpBuilder<(ins "::heavy::Value":$val, "::mlir::Value":$input)>
376-
];
377373
}
378374

379375
def heavy_MatchPairOp : HeavyOp<"match_pair", []> {
@@ -484,7 +480,7 @@ def heavy_SubpatternOp : HeavyOp<"subpattern", []> {
484480
let builders = [
485481
OpBuilder<(ins "::mlir::Value":$input,
486482
"::mlir::Value":$tail,
487-
"std::unique_ptr<::mlir::Region>":$body,
483+
"std::unique_ptr<::mlir::Region>&&":$body,
488484
"unsigned":$num_packs)>
489485
];
490486
}

heavy/include/heavy/Value.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ struct StatelessPointerTraitBase {
234234

235235
// all the bits??
236236
static constexpr int NumLowBitsAvailable =
237-
llvm::detail::ConstantLog2<alignof(void*)>::value;
237+
llvm::ConstantLog2<alignof(void*)>();
238238
};
239239
}}
240240

@@ -292,7 +292,7 @@ struct ValueSumType {
292292
}
293293

294294
static constexpr int NumLowBitsAvailable =
295-
llvm::detail::ConstantLog2<alignof(void*)>::value;
295+
llvm::ConstantLog2<alignof(void*)>();
296296
};
297297

298298
struct ContArgTraits {
@@ -304,7 +304,7 @@ struct ValueSumType {
304304
}
305305

306306
static constexpr int NumLowBitsAvailable =
307-
llvm::detail::ConstantLog2<alignof(void*)>::value;
307+
llvm::ConstantLog2<alignof(void*)>();
308308
};
309309

310310
using type = llvm::PointerSumType<SumKind,
@@ -866,18 +866,18 @@ class String final
866866
: ValueBase(ValueKind::String),
867867
Len(Length)
868868
{
869-
std::memset(getTrailingObjects<char>(), InitChar, Len);
869+
std::memset(getTrailingObjects(), InitChar, Len);
870870
// Set trailing null byte.
871-
*(getTrailingObjects<char>() + Len) = '\0';
871+
*(getTrailingObjects() + Len) = '\0';
872872
}
873873

874874
String(llvm::StringRef S)
875875
: ValueBase(ValueKind::String),
876876
Len(S.size())
877877
{
878-
std::memcpy(getTrailingObjects<char>(), S.data(), S.size());
878+
std::memcpy(getTrailingObjects(), S.data(), S.size());
879879
// Set trailing null byte.
880-
*(getTrailingObjects<char>() + Len) = '\0';
880+
*(getTrailingObjects() + Len) = '\0';
881881
}
882882

883883
template <typename ...StringRefs>
@@ -886,13 +886,13 @@ class String final
886886
Len(TotalLen)
887887
{
888888
std::array<llvm::StringRef, sizeof...(Ss)> Arr = {Ss...};
889-
char* StrData = getTrailingObjects<char>();
889+
char* StrData = getTrailingObjects();
890890
for (llvm::StringRef S : Arr) {
891891
std::memcpy(StrData, S.data(), S.size());
892892
StrData += S.size();
893893
}
894894
// Set trailing null byte.
895-
*(getTrailingObjects<char>() + Len) = '\0';
895+
*(getTrailingObjects() + Len) = '\0';
896896
}
897897

898898
static constexpr size_t sizeToAlloc(unsigned Length) {
@@ -903,11 +903,11 @@ class String final
903903
unsigned size() const { return Len; }
904904

905905
llvm::StringRef getView() const {
906-
return llvm::StringRef(getTrailingObjects<char>(), Len);
906+
return llvm::StringRef(getTrailingObjects(), Len);
907907
}
908908

909909
llvm::MutableArrayRef<char> getMutableView() {
910-
return llvm::MutableArrayRef(getTrailingObjects<char>(), Len);
910+
return llvm::MutableArrayRef(getTrailingObjects(), Len);
911911
}
912912

913913
bool Equiv(String* S) const {
@@ -1202,7 +1202,7 @@ class Syntax final
12021202
OpaqueFnPtrTy FnPtr;
12031203
unsigned StorageLen;
12041204

1205-
void* getStoragePtr() { return getTrailingObjects<char>(); }
1205+
void* getStoragePtr() { return getTrailingObjects(); }
12061206

12071207
public:
12081208
Syntax(OpaqueFn FnData)
@@ -1302,15 +1302,15 @@ class Vector final
13021302
: ValueBase(ValueKind::Vector),
13031303
Len(Vs.size())
13041304
{
1305-
std::memcpy(getTrailingObjects<Value>(), Vs.data(),
1305+
std::memcpy(getTrailingObjects(), Vs.data(),
13061306
Len * sizeof(Value));
13071307
}
13081308

13091309
Vector(Value V, unsigned N)
13101310
: ValueBase(ValueKind::Vector),
13111311
Len(N)
13121312
{
1313-
Value* Xs = getTrailingObjects<Value>();
1313+
Value* Xs = getTrailingObjects();
13141314
for (unsigned i = 0; i < Len; ++i) {
13151315
Xs[i] = V;
13161316
}
@@ -1333,17 +1333,17 @@ class Vector final
13331333

13341334
Value& get(unsigned I) {
13351335
assert(I < Len && "invalid index for vector");
1336-
return *(getTrailingObjects<Value>() + I);
1336+
return *(getTrailingObjects() + I);
13371337
}
13381338

13391339
llvm::ArrayRef<Value> getElements() const {
13401340
return llvm::ArrayRef<Value>(
1341-
getTrailingObjects<Value>(), Len);
1341+
getTrailingObjects(), Len);
13421342
}
13431343

13441344
llvm::MutableArrayRef<Value> getElements() {
13451345
return llvm::MutableArrayRef<Value>(
1346-
getTrailingObjects<Value>(), Len);
1346+
getTrailingObjects(), Len);
13471347
}
13481348

13491349
static bool classof(Value V) {
@@ -1398,7 +1398,7 @@ class Any final :
13981398
}
13991399

14001400
// Note that for stored pointers, this will return a pointer to a pointer.
1401-
void* getOpaquePtr() { return getTrailingObjects<char>(); }
1401+
void* getOpaquePtr() { return getTrailingObjects(); }
14021402

14031403
llvm::StringRef getObjData() {
14041404
return llvm::StringRef(static_cast<char*>(getOpaquePtr()), getObjectSize());
@@ -1556,12 +1556,12 @@ class EnvFrame final
15561556

15571557
llvm::ArrayRef<Binding*> getBindings() const {
15581558
return llvm::ArrayRef<Binding*>(
1559-
getTrailingObjects<Binding*>(), NumBindings);
1559+
getTrailingObjects(), NumBindings);
15601560
}
15611561

15621562
llvm::MutableArrayRef<Binding*> getBindings() {
15631563
return llvm::MutableArrayRef<Binding*>(
1564-
getTrailingObjects<Binding*>(), NumBindings);
1564+
getTrailingObjects(), NumBindings);
15651565
}
15661566

15671567
Value getLocalStack() const { return LocalStack; }

heavy/include/nbdl_gen/Nbdl.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def Nbdl_ScopeOp : Nbdl_Op<"scope", []> {
425425
let regions = (region SizedRegion<1>:$body);
426426

427427
let builders = [
428-
OpBuilder<(ins "std::unique_ptr<::mlir::Region>":$body)>
428+
OpBuilder<(ins "std::unique_ptr<::mlir::Region>&&":$body)>
429429
];
430430
}
431431

heavy/lib/Dialect.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,19 @@ void MatchArgsOp::build(mlir::OpBuilder& B, mlir::OperationState& OpState,
198198
MatchArgsOp::build(B, OpState, ResultTypes, Input);
199199
}
200200

201+
void MatchVectorOp::build(mlir::OpBuilder& B, mlir::OperationState& OpState,
202+
uint32_t Head, uint32_t Tail, mlir::Value Input) {
203+
llvm_unreachable("FIXME This is all very untested.");
204+
assert(Tail >= Head);
205+
unsigned NumResults = Tail - Head;
206+
mlir::Type HeavyValueT = B.getType<HeavyValueTy>();
207+
llvm::SmallVector<mlir::Type, 4> ResultTypes(NumResults, HeavyValueT);
208+
MatchVectorOp::build(B, OpState, ResultTypes, Head, Tail, Input);
209+
}
210+
201211
void SubpatternOp::build(mlir::OpBuilder& B, mlir::OperationState& OpState,
202212
mlir::Value Input, mlir::Value Tail,
203-
std::unique_ptr<mlir::Region> Body,
213+
std::unique_ptr<mlir::Region>&& Body,
204214
unsigned NumPacks) {
205215
mlir::Type HeavyValueT = B.getType<HeavyValueTy>();
206216
llvm::SmallVector<mlir::Type, 4> ResultTypes(NumPacks, HeavyValueT);
@@ -211,7 +221,7 @@ void SubpatternOp::build(mlir::OpBuilder& B, mlir::OperationState& OpState,
211221

212222
void ExpandPacksOp::build(mlir::OpBuilder& B, mlir::OperationState& OpState,
213223
mlir::Value Cdr, mlir::ValueRange Packs,
214-
std::unique_ptr<mlir::Region> Body) {
224+
std::unique_ptr<mlir::Region>&& Body) {
215225
mlir::Type HeavyValueT = B.getType<HeavyValueTy>();
216226
OpState.addOperands(Cdr);
217227
OpState.addOperands(Packs);

heavy/lib/Nbdl.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void build_match_params_impl(Context& C, ValueRefs Args) {
102102
/*ResultTypes*/{});
103103

104104
// Create the function.
105-
auto FuncOp = Builder.create<mlir::func::FuncOp>(MLoc, Name, FT);
105+
auto FuncOp = mlir::func::FuncOp::create(Builder, MLoc, Name, FT);
106106
FuncOp.addEntryBlock();
107107

108108
heavy::Value Thunk = C.CreateLambda([FuncOp](Context& C, ValueRefs) mutable {
@@ -147,7 +147,7 @@ void build_overload_impl(Context& C, ValueRefs Args) {
147147
llvm::StringRef Typename = TypenameArg.getStringRef();
148148
mlir::Location MLoc = mlir::OpaqueLoc::get(Loc.getOpaqueEncoding(),
149149
Builder->getContext());
150-
auto OverloadOp = Builder->create<nbdl_gen::OverloadOp>(MLoc, Typename);
150+
auto OverloadOp = nbdl_gen::OverloadOp::create(*Builder, MLoc, Typename);
151151
if (!Callback)
152152
return C.Cont();
153153

@@ -191,7 +191,7 @@ void build_match_if_impl(Context& C, ValueRefs Args) {
191191

192192
mlir::Location MLoc = mlir::OpaqueLoc::get(Loc.getOpaqueEncoding(),
193193
Builder->getContext());
194-
auto MatchIfOp = Builder->create<nbdl_gen::MatchIfOp>(MLoc, Input, Pred);
194+
auto MatchIfOp = nbdl_gen::MatchIfOp::create(*Builder, MLoc, Input, Pred);
195195
MatchIfOp.getThenRegion().emplaceBlock();
196196
MatchIfOp.getElseRegion().emplaceBlock();
197197

@@ -278,7 +278,8 @@ void close_previous_scope(Context& C, ValueRefs Args) {
278278
mlir::Block& NewBlock = ScopeBody->emplaceBlock();
279279
while (!Block->empty())
280280
Block->front().moveBefore(&NewBlock, NewBlock.end());
281-
mlir::Operation* ScopeOp = Builder->create<nbdl_gen::ScopeOp>(Loc, std::move(ScopeBody));
281+
mlir::Operation* ScopeOp = nbdl_gen::ScopeOp::create(
282+
*Builder, Loc, std::move(ScopeBody));
282283
Builder->setInsertionPointAfter(ScopeOp);
283284

284285
C.Cont();
@@ -358,7 +359,7 @@ void HEAVY_NBDL_INIT(heavy::Context& C) {
358359
mlir::OpBuilder Builder(C.MLIRContext.get());
359360
mlir::Location Loc = Builder.getUnknownLoc();
360361
mlir::ModuleOp ModuleOp
361-
= Builder.create<mlir::ModuleOp>(Loc, "nbdl_gen_module");
362+
= mlir::ModuleOp::create(Builder, Loc, "nbdl_gen_module");
362363

363364
heavy::nbdl_bind_var::current_nbdl_module.set(C, ModuleOp.getOperation());
364365
heavy::nbdl_bind_var::translate_cpp = heavy::nbdl_bind::translate_cpp;

0 commit comments

Comments
 (0)