Skip to content

Commit 50e4ca3

Browse files
mariusz-sikora-at-amdFlakebi
authored andcommitted
Change all 'Init' pointers to const
This change reflect upstream change: llvm/llvm-project#112705
1 parent 052d8b8 commit 50e4ca3

File tree

13 files changed

+54
-53
lines changed

13 files changed

+54
-53
lines changed

include/llvm-dialects/TableGen/Constraints.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@ class ConstraintSystem {
7676

7777
llvm::ArrayRef<Variable *> variables() const { return m_variables; }
7878

79-
bool addConstraint(llvm::raw_ostream &errs, llvm::Init *init, Variable *self);
79+
bool addConstraint(llvm::raw_ostream &errs, const llvm::Init *init,
80+
Variable *self);
8081
void merge(ConstraintSystem &&rhs);
8182

8283
void print(llvm::raw_ostream &out, llvm::StringRef prefix) const;
8384
void dump() const;
8485

8586
private:
86-
bool addConstraintImpl(llvm::raw_ostream &errs, llvm::Init *init,
87+
bool addConstraintImpl(llvm::raw_ostream &errs, const llvm::Init *init,
8788
Variable *self);
8889
void addVariable(Variable *variable);
8990
void addGlobalVariable(Variable *variable);
@@ -117,7 +118,7 @@ class Constraint {
117118
virtual void print(llvm::raw_ostream &out, llvm::StringRef prefix) const = 0;
118119

119120
Kind getKind() const { return m_kind; }
120-
llvm::Init *getInit() const { return m_init; }
121+
const llvm::Init *getInit() const { return m_init; }
121122
Variable *getSelf() const { return m_self; }
122123
llvm::ArrayRef<Variable *> variables() const { return m_variables; }
123124

@@ -134,7 +135,7 @@ class Constraint {
134135

135136
/// Only for error messages: The TableGen init (if any) from which this
136137
/// constraint was derived.
137-
llvm::Init *m_init = nullptr;
138+
const llvm::Init *m_init = nullptr;
138139

139140
/// Only for error messages: The variable in the valued position that this
140141
/// constraint originally appeared in (if any).
@@ -178,13 +179,15 @@ class LogicOr : public Constraint {
178179
void print(llvm::raw_ostream &out, llvm::StringRef prefix) const override;
179180

180181
llvm::ArrayRef<ConstraintSystem> branches() const { return m_branches; }
181-
llvm::ArrayRef<llvm::Init *> branchInits() const { return m_branchInits; }
182+
llvm::ArrayRef<const llvm::Init *> branchInits() const {
183+
return m_branchInits;
184+
}
182185

183186
private:
184187
std::vector<ConstraintSystem> m_branches;
185188

186189
/// Only for error messages.
187-
std::vector<llvm::Init *> m_branchInits;
190+
std::vector<const llvm::Init *> m_branchInits;
188191
};
189192

190193
class MetaType {
@@ -226,7 +229,7 @@ class Attr : public MetaType {
226229

227230
llvm::StringRef getName() const;
228231
llvm::StringRef getCppType() const { return m_cppType; }
229-
llvm::Init *getLlvmType() const { return m_llvmType; }
232+
const llvm::Init *getLlvmType() const { return m_llvmType; }
230233
llvm::StringRef getToLlvmValue() const { return m_toLlvmValue; }
231234
llvm::StringRef getFromLlvmValue() const { return m_fromLlvmValue; }
232235
llvm::StringRef getToUnsigned() const { return m_toUnsigned; }
@@ -236,7 +239,7 @@ class Attr : public MetaType {
236239

237240
// Set the LLVMType once -- used during initialization to break a circular
238241
// dependency in how IntegerType is defined.
239-
void setLlvmType(llvm::Init *llvmType) {
242+
void setLlvmType(const llvm::Init *llvmType) {
240243
assert(!m_llvmType);
241244
assert(llvmType);
242245
m_llvmType = llvmType;
@@ -245,7 +248,7 @@ class Attr : public MetaType {
245248
private:
246249
RecordTy *m_record = nullptr;
247250
std::string m_cppType;
248-
llvm::Init *m_llvmType = nullptr;
251+
const llvm::Init *m_llvmType = nullptr;
249252
std::string m_toLlvmValue;
250253
std::string m_fromLlvmValue;
251254
std::string m_toUnsigned;

include/llvm-dialects/TableGen/DialectType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DialectType : public BaseCppPredicate {
3535
}
3636

3737
bool init(llvm::raw_ostream &errs, GenDialectsContext &context,
38-
llvm::Init *theInit) override final;
38+
const llvm::Init *theInit) override final;
3939

4040
llvm::ArrayRef<NamedValue> typeArguments() const {
4141
return arguments().drop_front(1);

include/llvm-dialects/TableGen/Dialects.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,28 @@ class GenDialectsContext {
7474
const llvm::DenseSet<llvm::StringRef> &dialects);
7575

7676
Trait *getTrait(RecordTy *traitRec);
77-
Predicate *getPredicate(llvm::Init *init, llvm::raw_ostream &errs);
77+
Predicate *getPredicate(const llvm::Init *init, llvm::raw_ostream &errs);
7878
Attr *getAttr(RecordTy *record, llvm::raw_ostream &errs);
7979
OpClass *getOpClass(RecordTy *opClassRec);
8080
GenDialect *getDialect(RecordTy *dialectRec);
8181

82-
llvm::Init *getVoidTy() const { return m_voidTy; }
83-
llvm::Init *getAny() const { return m_any; }
82+
const llvm::Init *getVoidTy() const { return m_voidTy; }
83+
const llvm::Init *getAny() const { return m_any; }
8484

8585
private:
8686
GenDialectsContext(const GenDialectsContext &rhs) = delete;
8787
GenDialectsContext &operator=(const GenDialectsContext &rhs) = delete;
8888
GenDialectsContext(GenDialectsContext &&rhs) = delete;
8989
GenDialectsContext &operator=(GenDialectsContext &&rhs) = delete;
9090

91-
Predicate *getPredicateImpl(llvm::Init *record, llvm::raw_ostream &errs);
91+
Predicate *getPredicateImpl(const llvm::Init *record,
92+
llvm::raw_ostream &errs);
9293

93-
llvm::Init *m_voidTy = nullptr;
94-
llvm::Init *m_any = nullptr;
94+
const llvm::Init *m_voidTy = nullptr;
95+
const llvm::Init *m_any = nullptr;
9596
bool m_attrsComplete = false;
9697
llvm::DenseMap<RecordTy *, std::unique_ptr<Trait>> m_traits;
97-
llvm::DenseMap<llvm::Init *, std::unique_ptr<Predicate>> m_predicates;
98+
llvm::DenseMap<const llvm::Init *, std::unique_ptr<Predicate>> m_predicates;
9899
llvm::DenseMap<RecordTy *, std::unique_ptr<Attr>> m_attrs;
99100
llvm::DenseMap<RecordTy *, std::unique_ptr<OpClass>> m_opClasses;
100101
llvm::DenseMap<RecordTy *, std::unique_ptr<GenDialect>> m_dialects;

include/llvm-dialects/TableGen/Evaluator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class Evaluator {
138138
bool checkApplyCapture(bool writeErrs, const Apply *apply);
139139
bool checkLogicOr(bool writeErrs, const LogicOr *logicOr);
140140
void checkAssignment(bool writeErrs, Variable *variable, std::string value,
141-
llvm::Init *constraint);
141+
const llvm::Init *constraint);
142142
};
143143

144144
} // namespace llvm_dialects

include/llvm-dialects/TableGen/NamedValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct NamedValue {
4040
std::string name;
4141

4242
/// The implied constraint on the value.
43-
llvm::Init *constraint = nullptr;
43+
const llvm::Init *constraint = nullptr;
4444

4545
enum class Parser {
4646
ApplyArguments,
@@ -52,7 +52,7 @@ struct NamedValue {
5252

5353
static std::optional<std::vector<NamedValue>>
5454
parseList(llvm::raw_ostream &errs, GenDialectsContext &context,
55-
llvm::DagInit *init, unsigned begin, Parser mode);
55+
const llvm::DagInit *init, unsigned begin, Parser mode);
5656

5757
std::string toString() const;
5858
};

include/llvm-dialects/TableGen/Predicates.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ class Predicate {
4141

4242
static std::unique_ptr<Predicate> parse(llvm::raw_ostream &errs,
4343
GenDialectsContext &context,
44-
llvm::Init *theInit);
44+
const llvm::Init *theInit);
4545

4646
virtual bool init(llvm::raw_ostream &errs, GenDialectsContext &genContext,
47-
llvm::Init *theInit);
47+
const llvm::Init *theInit);
4848

4949
Kind getKind() const { return m_kind; }
50-
llvm::Init *getInit() const { return m_init; }
50+
const llvm::Init *getInit() const { return m_init; }
5151
llvm::ArrayRef<NamedValue> arguments() const { return m_arguments; }
5252
bool canDerive(unsigned argumentIndex) const {
5353
assert(argumentIndex < m_canDerive.size());
@@ -59,7 +59,7 @@ class Predicate {
5959
Predicate(Kind kind) : m_kind(kind) {}
6060

6161
const Kind m_kind;
62-
llvm::Init *m_init = nullptr;
62+
const llvm::Init *m_init = nullptr;
6363
std::vector<NamedValue> m_arguments;
6464

6565
/// Whether the constraint can be fully checked given only the "self"
@@ -82,7 +82,7 @@ class TgPredicate : public Predicate {
8282
}
8383

8484
bool init(llvm::raw_ostream &errs, GenDialectsContext &genContext,
85-
llvm::Init *theInit) override final;
85+
const llvm::Init *theInit) override final;
8686

8787
const ConstraintSystem &getSystem() const { return m_system; }
8888
llvm::ArrayRef<Variable *> variables() const { return m_variables; }
@@ -122,15 +122,15 @@ class CppPredicate : public BaseCppPredicate {
122122
CppPredicate() : BaseCppPredicate(Kind::CppPredicate) {}
123123

124124
bool init(llvm::raw_ostream &errs, GenDialectsContext &genContext,
125-
llvm::Init *theInit) override final;
125+
const llvm::Init *theInit) override final;
126126
};
127127

128128
class Constant : public BaseCppPredicate {
129129
public:
130130
Constant() : BaseCppPredicate(Kind::Constant) {}
131131

132132
bool init(llvm::raw_ostream &errs, GenDialectsContext &genContext,
133-
llvm::Init *theInit) override final;
133+
const llvm::Init *theInit) override final;
134134
};
135135

136136
} // namespace llvm_dialects

lib/TableGen/Constraints.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void ConstraintSystem::dump() const {
8181
print(dbgs(), " ");
8282
}
8383

84-
bool ConstraintSystem::addConstraint(raw_ostream &errs, Init *init,
84+
bool ConstraintSystem::addConstraint(raw_ostream &errs, const Init *init,
8585
Variable *self) {
8686
if (!addConstraintImpl(errs, init, self)) {
8787
errs << ".. in " << init->getAsString() << '\n';
@@ -90,7 +90,7 @@ bool ConstraintSystem::addConstraint(raw_ostream &errs, Init *init,
9090
return true;
9191
}
9292

93-
bool ConstraintSystem::addConstraintImpl(raw_ostream &errs, Init *init,
93+
bool ConstraintSystem::addConstraintImpl(raw_ostream &errs, const Init *init,
9494
Variable *self) {
9595
if (auto *dag = dyn_cast<DagInit>(init)) {
9696
RecordTy *op = dag->getOperatorAsDef({});
@@ -115,7 +115,7 @@ bool ConstraintSystem::addConstraintImpl(raw_ostream &errs, Init *init,
115115
if (!isValidOperand(i, op->getName()))
116116
return false;
117117

118-
Init *operand = dag->getArg(i);
118+
const Init *operand = dag->getArg(i);
119119
if (!addConstraint(errs, operand, self))
120120
return false;
121121
}
@@ -138,7 +138,7 @@ bool ConstraintSystem::addConstraintImpl(raw_ostream &errs, Init *init,
138138
if (!isValidOperand(i, op->getName()))
139139
return false;
140140

141-
Init *operand = dag->getArg(i);
141+
const Init *operand = dag->getArg(i);
142142
ConstraintSystem branchSystem(m_context, m_scope);
143143
if (!branchSystem.addConstraint(errs, operand, self))
144144
return false;
@@ -165,12 +165,7 @@ bool ConstraintSystem::addConstraintImpl(raw_ostream &errs, Init *init,
165165
result->m_self = self;
166166

167167
auto *dag = dyn_cast<DagInit>(init);
168-
Init *predicateInit;
169-
if (dag) {
170-
predicateInit = dag->getOperator();
171-
} else {
172-
predicateInit = init;
173-
}
168+
const Init *predicateInit = dag ? dag->getOperator() : init;
174169

175170
result->m_predicate = m_context.getPredicate(predicateInit, errs);
176171
if (!result->m_predicate)

lib/TableGen/DialectType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace llvm;
2626
using namespace llvm_dialects;
2727

2828
bool DialectType::init(raw_ostream &errs, GenDialectsContext &context,
29-
Init *theInit) {
29+
const Init *theInit) {
3030
if (!BaseCppPredicate::init(errs, context, theInit))
3131
return false;
3232

lib/TableGen/Dialects.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,16 @@ Trait *GenDialectsContext::getTrait(RecordTy *traitRec) {
8888
return result.get();
8989
}
9090

91-
Predicate *GenDialectsContext::getPredicate(Init *init, raw_ostream &errs) {
91+
Predicate *GenDialectsContext::getPredicate(const Init *init,
92+
raw_ostream &errs) {
9293
Predicate *op = getPredicateImpl(init, errs);
9394
if (!op)
9495
errs << "... while looking up predicate: " << init->getAsString() << '\n';
9596
return op;
9697
}
9798

98-
Predicate *GenDialectsContext::getPredicateImpl(Init *init, raw_ostream &errs) {
99+
Predicate *GenDialectsContext::getPredicateImpl(const Init *init,
100+
raw_ostream &errs) {
99101
auto it = m_predicates.find(init);
100102
if (it != m_predicates.end()) {
101103
if (!it->second)

lib/TableGen/Evaluator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ bool Evaluator::checkLogicOr(bool writeErrs, const LogicOr *logicOr) {
667667
}
668668

669669
void Evaluator::checkAssignment(bool writeErrs, Variable *variable,
670-
std::string value, Init *constraint) {
670+
std::string value, const Init *constraint) {
671671
assert(variable);
672672
assert(!value.empty());
673673

0 commit comments

Comments
 (0)