Skip to content

Commit 050b73c

Browse files
committed
Unify the way we serialise unimplemented constructs.
Namely: - Rename String operands to Unimplemented operands. - Use discriminant 255 for consistency. - Make unimplemented instructions lower to an instruction with opcode "unimplemented" and one unimplemented operand containing the LLVM IR we couldn't handle.
1 parent 08f0d52 commit 050b73c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/YkIR/YkIRWriter.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ enum OpCode {
5151
enum OperandKind {
5252
Constant = 0,
5353
LocalVariable,
54-
String,
54+
UnimplementedOperand = 255,
5555
};
5656

5757
enum TypeKind {
@@ -153,15 +153,15 @@ class YkIRWriter {
153153
}
154154

155155
void serialiseStringOperand(const char *S) {
156-
OutStreamer.emitInt8(OperandKind::String);
156+
OutStreamer.emitInt8(OperandKind::UnimplementedOperand);
157157
serialiseString(S);
158158
}
159159

160160
// YKFIXME: This allows programs which we haven't yet defined a
161161
// lowering for to compile. For now We just emit a string operand containing
162162
// the unhandled LLVM operand in textual form.
163163
void serialiseUnimplementedOperand(Value *V) {
164-
OutStreamer.emitInt8(OperandKind::String);
164+
OutStreamer.emitInt8(OperandKind::UnimplementedOperand);
165165
serialiseString(toString(V));
166166
}
167167

@@ -203,13 +203,15 @@ class YkIRWriter {
203203
serialiseUnimplementedInstruction(I);
204204
}
205205

206+
// An unimplemented instruction is lowered to an instruction with one
207+
// unimplemented operand containing the textual LLVM IR we couldn't handle.
206208
void serialiseUnimplementedInstruction(Instruction *I) {
207209
// opcode:
208210
serialiseOpcode(UnimplementedInstruction);
209211
// num_operands:
210212
OutStreamer.emitInt32(1);
211213
// problem instruction:
212-
serialiseStringOperand(toString(I).data());
214+
serialiseUnimplementedOperand(I);
213215
}
214216

215217
void serialiseBlock(BasicBlock &BB) {

0 commit comments

Comments
 (0)