Skip to content
This repository was archived by the owner on Jan 1, 2023. It is now read-only.

Commit ad30df4

Browse files
committed
[WebAssembly] Rename except_ref type to exnref
Summary: We agreed to rename `except_ref` to `exnref` for consistency with other reference types in WebAssembly/exception-handling#79. This also renames WebAssemblyInstrExceptRef.td to WebAssemblyInstrRef.td in order to use the file for other reference types in future. Reviewers: dschuff Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64703 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366145 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent bfdd719 commit ad30df4

27 files changed

+139
-144
lines changed

include/llvm/BinaryFormat/Wasm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ enum : unsigned {
224224
WASM_TYPE_F64 = 0x7C,
225225
WASM_TYPE_V128 = 0x7B,
226226
WASM_TYPE_FUNCREF = 0x70,
227-
WASM_TYPE_EXCEPT_REF = 0x68,
227+
WASM_TYPE_EXNREF = 0x68,
228228
WASM_TYPE_FUNC = 0x60,
229229
WASM_TYPE_NORESULT = 0x40, // for blocks with no result values
230230
};
@@ -332,7 +332,7 @@ enum class ValType {
332332
F32 = WASM_TYPE_F32,
333333
F64 = WASM_TYPE_F64,
334334
V128 = WASM_TYPE_V128,
335-
EXCEPT_REF = WASM_TYPE_EXCEPT_REF,
335+
EXNREF = WASM_TYPE_EXNREF,
336336
};
337337

338338
struct WasmSignature {

include/llvm/CodeGen/ValueTypes.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def x86mmx : ValueType<64 , 125>; // X86 MMX value
160160
def FlagVT : ValueType<0 , 126>; // Pre-RA sched glue
161161
def isVoid : ValueType<0 , 127>; // Produces no value
162162
def untyped: ValueType<8 , 128>; // Produces an untyped value
163-
def ExceptRef: ValueType<0, 129>; // WebAssembly's except_ref type
163+
def exnref: ValueType<0, 129>; // WebAssembly's exnref type
164164
def token : ValueType<0 , 248>; // TokenTy
165165
def MetadataVT: ValueType<0, 249>; // Metadata
166166

include/llvm/Support/MachineValueType.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ namespace llvm {
206206
// unspecified type. The register class
207207
// will be determined by the opcode.
208208

209-
ExceptRef = 129, // WebAssembly's except_ref type
209+
exnref = 129, // WebAssembly's exnref type
210210

211211
FIRST_VALUETYPE = 1, // This is always the beginning of the list.
212212
LAST_VALUETYPE = 130, // This always remains at the end of the list.
@@ -811,7 +811,7 @@ namespace llvm {
811811
case v1024f32: return 32768;
812812
case v2048i32:
813813
case v2048f32: return 65536;
814-
case ExceptRef: return 0; // opaque type
814+
case exnref: return 0; // opaque type
815815
}
816816
}
817817

lib/CodeGen/ValueTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ std::string EVT::getEVTString() const {
207207
case MVT::v8f64: return "v8f64";
208208
case MVT::Metadata:return "Metadata";
209209
case MVT::Untyped: return "Untyped";
210-
case MVT::ExceptRef: return "ExceptRef";
210+
case MVT::exnref : return "exnref";
211211
}
212212
}
213213

lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
308308
Type == "i32x4" || Type == "i64x2" || Type == "f32x4" ||
309309
Type == "f64x2")
310310
return wasm::ValType::V128;
311-
if (Type == "except_ref")
312-
return wasm::ValType::EXCEPT_REF;
311+
if (Type == "exnref")
312+
return wasm::ValType::EXNREF;
313313
return Optional<wasm::ValType>();
314314
}
315315

@@ -320,7 +320,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
320320
.Case("f32", WebAssembly::ExprType::F32)
321321
.Case("f64", WebAssembly::ExprType::F64)
322322
.Case("v128", WebAssembly::ExprType::V128)
323-
.Case("except_ref", WebAssembly::ExprType::ExceptRef)
323+
.Case("exnref", WebAssembly::ExprType::Exnref)
324324
.Case("void", WebAssembly::ExprType::Void)
325325
.Default(WebAssembly::ExprType::Invalid);
326326
}

lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ const char *llvm::WebAssembly::anyTypeToString(unsigned Ty) {
282282
return "funcref";
283283
case wasm::WASM_TYPE_FUNC:
284284
return "func";
285-
case wasm::WASM_TYPE_EXCEPT_REF:
286-
return "except_ref";
285+
case wasm::WASM_TYPE_EXNREF:
286+
return "exnref";
287287
case wasm::WASM_TYPE_NORESULT:
288288
return "void";
289289
default:

lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ wasm::ValType WebAssembly::toValType(const MVT &Ty) {
146146
case MVT::v4f32:
147147
case MVT::v2f64:
148148
return wasm::ValType::V128;
149-
case MVT::ExceptRef:
150-
return wasm::ValType::EXCEPT_REF;
149+
case MVT::exnref:
150+
return wasm::ValType::EXNREF;
151151
default:
152152
llvm_unreachable("unexpected type");
153153
}

lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ enum class ExprType : unsigned {
130130
F32 = 0x7D,
131131
F64 = 0x7C,
132132
V128 = 0x7B,
133-
ExceptRef = 0x68,
133+
Exnref = 0x68,
134134
Invalid = 0x00
135135
};
136136

@@ -403,8 +403,8 @@ inline bool isCopy(unsigned Opc) {
403403
case WebAssembly::COPY_F64_S:
404404
case WebAssembly::COPY_V128:
405405
case WebAssembly::COPY_V128_S:
406-
case WebAssembly::COPY_EXCEPT_REF:
407-
case WebAssembly::COPY_EXCEPT_REF_S:
406+
case WebAssembly::COPY_EXNREF:
407+
case WebAssembly::COPY_EXNREF_S:
408408
return true;
409409
default:
410410
return false;
@@ -453,8 +453,8 @@ inline bool isCallDirect(unsigned Opc) {
453453
case WebAssembly::CALL_v4f32_S:
454454
case WebAssembly::CALL_v2f64:
455455
case WebAssembly::CALL_v2f64_S:
456-
case WebAssembly::CALL_ExceptRef:
457-
case WebAssembly::CALL_ExceptRef_S:
456+
case WebAssembly::CALL_exnref:
457+
case WebAssembly::CALL_exnref_S:
458458
case WebAssembly::RET_CALL:
459459
case WebAssembly::RET_CALL_S:
460460
return true;
@@ -487,8 +487,8 @@ inline bool isCallIndirect(unsigned Opc) {
487487
case WebAssembly::CALL_INDIRECT_v4f32_S:
488488
case WebAssembly::CALL_INDIRECT_v2f64:
489489
case WebAssembly::CALL_INDIRECT_v2f64_S:
490-
case WebAssembly::CALL_INDIRECT_ExceptRef:
491-
case WebAssembly::CALL_INDIRECT_ExceptRef_S:
490+
case WebAssembly::CALL_INDIRECT_exnref:
491+
case WebAssembly::CALL_INDIRECT_exnref_S:
492492
case WebAssembly::RET_CALL_INDIRECT:
493493
case WebAssembly::RET_CALL_INDIRECT_S:
494494
return true;
@@ -530,8 +530,8 @@ inline unsigned getCalleeOpNo(unsigned Opc) {
530530
case WebAssembly::CALL_v4f32_S:
531531
case WebAssembly::CALL_v2f64:
532532
case WebAssembly::CALL_v2f64_S:
533-
case WebAssembly::CALL_ExceptRef:
534-
case WebAssembly::CALL_ExceptRef_S:
533+
case WebAssembly::CALL_exnref:
534+
case WebAssembly::CALL_exnref_S:
535535
case WebAssembly::CALL_INDIRECT_i32:
536536
case WebAssembly::CALL_INDIRECT_i32_S:
537537
case WebAssembly::CALL_INDIRECT_i64:
@@ -552,8 +552,8 @@ inline unsigned getCalleeOpNo(unsigned Opc) {
552552
case WebAssembly::CALL_INDIRECT_v4f32_S:
553553
case WebAssembly::CALL_INDIRECT_v2f64:
554554
case WebAssembly::CALL_INDIRECT_v2f64_S:
555-
case WebAssembly::CALL_INDIRECT_ExceptRef:
556-
case WebAssembly::CALL_INDIRECT_ExceptRef_S:
555+
case WebAssembly::CALL_INDIRECT_exnref:
556+
case WebAssembly::CALL_INDIRECT_exnref_S:
557557
return 1;
558558
default:
559559
llvm_unreachable("Not a call instruction");

lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void WebAssemblyCFGStackify::placeBlockMarker(MachineBasicBlock &MBB) {
308308

309309
// Add the BLOCK.
310310

311-
// 'br_on_exn' extracts except_ref object and pushes variable number of values
311+
// 'br_on_exn' extracts exnref object and pushes variable number of values
312312
// depending on its tag. For C++ exception, its a single i32 value, and the
313313
// generated code will be in the form of:
314314
// block i32
@@ -766,11 +766,11 @@ bool WebAssemblyCFGStackify::fixUnwindMismatches(MachineFunction &MF) {
766766
// Note that the new wrapping block/end_block will be generated later in
767767
// placeBlockMarker.
768768
//
769-
// TODO Currently local.set and local.gets are generated to move except_ref
770-
// value created by catches. That's because we don't support yielding values
771-
// from a block in LLVM machine IR yet, even though it is supported by wasm.
772-
// Delete unnecessary local.get/local.sets once yielding values from a block
773-
// is supported. The full EH spec requires multi-value support to do this, but
769+
// TODO Currently local.set and local.gets are generated to move exnref value
770+
// created by catches. That's because we don't support yielding values from a
771+
// block in LLVM machine IR yet, even though it is supported by wasm. Delete
772+
// unnecessary local.get/local.sets once yielding values from a block is
773+
// supported. The full EH spec requires multi-value support to do this, but
774774
// for C++ we don't yet need it because we only throw a single i32.
775775
//
776776
// ---
@@ -834,7 +834,7 @@ bool WebAssemblyCFGStackify::fixUnwindMismatches(MachineFunction &MF) {
834834
DenseMap<MachineBasicBlock *, SmallVector<TryRange, 4>> UnwindDestToTryRanges;
835835
// In new CFG, <destination to branch to, a vector of try ranges>
836836
DenseMap<MachineBasicBlock *, SmallVector<TryRange, 4>> BrDestToTryRanges;
837-
// In new CFG, <destination to branch to, register containing except_ref>
837+
// In new CFG, <destination to branch to, register containing exnref>
838838
DenseMap<MachineBasicBlock *, unsigned> BrDestToExnReg;
839839

840840
// Gather possibly throwing calls (i.e., previously invokes) whose current
@@ -936,8 +936,7 @@ bool WebAssemblyCFGStackify::fixUnwindMismatches(MachineFunction &MF) {
936936
// of the function with a local.get and a rethrow instruction.
937937
if (NeedAppendixBlock) {
938938
auto *AppendixBB = getAppendixBlock(MF);
939-
unsigned ExnReg =
940-
MRI.createVirtualRegister(&WebAssembly::EXCEPT_REFRegClass);
939+
unsigned ExnReg = MRI.createVirtualRegister(&WebAssembly::EXNREFRegClass);
941940
BuildMI(AppendixBB, DebugLoc(), TII.get(WebAssembly::RETHROW))
942941
.addReg(ExnReg);
943942
// These instruction ranges should branch to this appendix BB.
@@ -1225,8 +1224,8 @@ void WebAssemblyCFGStackify::fixEndsAtEndOfFunction(MachineFunction &MF) {
12251224
case MVT::v2f64:
12261225
RetType = WebAssembly::ExprType::V128;
12271226
break;
1228-
case MVT::ExceptRef:
1229-
RetType = WebAssembly::ExprType::ExceptRef;
1227+
case MVT::exnref:
1228+
RetType = WebAssembly::ExprType::Exnref;
12301229
break;
12311230
default:
12321231
llvm_unreachable("unexpected return type");

lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ static unsigned getNonPseudoCallIndirectOpcode(const MachineInstr &MI) {
8585
return CALL_INDIRECT_v4f32;
8686
case PCALL_INDIRECT_v2f64:
8787
return CALL_INDIRECT_v2f64;
88-
case PCALL_INDIRECT_ExceptRef:
89-
return CALL_INDIRECT_ExceptRef;
88+
case PCALL_INDIRECT_exnref:
89+
return CALL_INDIRECT_exnref;
9090
case PRET_CALL_INDIRECT:
9191
return RET_CALL_INDIRECT;
9292
default:

lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ static unsigned getDropOpcode(const TargetRegisterClass *RC) {
9090
return WebAssembly::DROP_F64;
9191
if (RC == &WebAssembly::V128RegClass)
9292
return WebAssembly::DROP_V128;
93-
if (RC == &WebAssembly::EXCEPT_REFRegClass)
94-
return WebAssembly::DROP_EXCEPT_REF;
93+
if (RC == &WebAssembly::EXNREFRegClass)
94+
return WebAssembly::DROP_EXNREF;
9595
llvm_unreachable("Unexpected register class");
9696
}
9797

@@ -107,8 +107,8 @@ static unsigned getLocalGetOpcode(const TargetRegisterClass *RC) {
107107
return WebAssembly::LOCAL_GET_F64;
108108
if (RC == &WebAssembly::V128RegClass)
109109
return WebAssembly::LOCAL_GET_V128;
110-
if (RC == &WebAssembly::EXCEPT_REFRegClass)
111-
return WebAssembly::LOCAL_GET_EXCEPT_REF;
110+
if (RC == &WebAssembly::EXNREFRegClass)
111+
return WebAssembly::LOCAL_GET_EXNREF;
112112
llvm_unreachable("Unexpected register class");
113113
}
114114

@@ -124,8 +124,8 @@ static unsigned getLocalSetOpcode(const TargetRegisterClass *RC) {
124124
return WebAssembly::LOCAL_SET_F64;
125125
if (RC == &WebAssembly::V128RegClass)
126126
return WebAssembly::LOCAL_SET_V128;
127-
if (RC == &WebAssembly::EXCEPT_REFRegClass)
128-
return WebAssembly::LOCAL_SET_EXCEPT_REF;
127+
if (RC == &WebAssembly::EXNREFRegClass)
128+
return WebAssembly::LOCAL_SET_EXNREF;
129129
llvm_unreachable("Unexpected register class");
130130
}
131131

@@ -141,8 +141,8 @@ static unsigned getLocalTeeOpcode(const TargetRegisterClass *RC) {
141141
return WebAssembly::LOCAL_TEE_F64;
142142
if (RC == &WebAssembly::V128RegClass)
143143
return WebAssembly::LOCAL_TEE_V128;
144-
if (RC == &WebAssembly::EXCEPT_REFRegClass)
145-
return WebAssembly::LOCAL_TEE_EXCEPT_REF;
144+
if (RC == &WebAssembly::EXNREFRegClass)
145+
return WebAssembly::LOCAL_TEE_EXNREF;
146146
llvm_unreachable("Unexpected register class");
147147
}
148148

@@ -158,8 +158,8 @@ static MVT typeForRegClass(const TargetRegisterClass *RC) {
158158
return MVT::f64;
159159
if (RC == &WebAssembly::V128RegClass)
160160
return MVT::v16i8;
161-
if (RC == &WebAssembly::EXCEPT_REFRegClass)
162-
return MVT::ExceptRef;
161+
if (RC == &WebAssembly::EXNREFRegClass)
162+
return MVT::exnref;
163163
llvm_unreachable("unrecognized register class");
164164
}
165165

lib/Target/WebAssembly/WebAssemblyFastISel.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class WebAssemblyFastISel final : public FastISel {
129129
case MVT::i64:
130130
case MVT::f32:
131131
case MVT::f64:
132-
case MVT::ExceptRef:
132+
case MVT::exnref:
133133
return VT;
134134
case MVT::f16:
135135
return MVT::f32;
@@ -698,9 +698,9 @@ bool WebAssemblyFastISel::fastLowerArguments() {
698698
Opc = WebAssembly::ARGUMENT_v2f64;
699699
RC = &WebAssembly::V128RegClass;
700700
break;
701-
case MVT::ExceptRef:
702-
Opc = WebAssembly::ARGUMENT_ExceptRef;
703-
RC = &WebAssembly::EXCEPT_REFRegClass;
701+
case MVT::exnref:
702+
Opc = WebAssembly::ARGUMENT_exnref;
703+
RC = &WebAssembly::EXNREFRegClass;
704704
break;
705705
default:
706706
return false;
@@ -815,10 +815,10 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) {
815815
: WebAssembly::PCALL_INDIRECT_v2f64;
816816
ResultReg = createResultReg(&WebAssembly::V128RegClass);
817817
break;
818-
case MVT::ExceptRef:
819-
Opc = IsDirect ? WebAssembly::CALL_ExceptRef
820-
: WebAssembly::PCALL_INDIRECT_ExceptRef;
821-
ResultReg = createResultReg(&WebAssembly::EXCEPT_REFRegClass);
818+
case MVT::exnref:
819+
Opc = IsDirect ? WebAssembly::CALL_exnref
820+
: WebAssembly::PCALL_INDIRECT_exnref;
821+
ResultReg = createResultReg(&WebAssembly::EXNREFRegClass);
822822
break;
823823
default:
824824
return false;
@@ -921,9 +921,9 @@ bool WebAssemblyFastISel::selectSelect(const Instruction *I) {
921921
Opc = WebAssembly::SELECT_F64;
922922
RC = &WebAssembly::F64RegClass;
923923
break;
924-
case MVT::ExceptRef:
925-
Opc = WebAssembly::SELECT_EXCEPT_REF;
926-
RC = &WebAssembly::EXCEPT_REFRegClass;
924+
case MVT::exnref:
925+
Opc = WebAssembly::SELECT_EXNREF;
926+
RC = &WebAssembly::EXNREFRegClass;
927927
break;
928928
default:
929929
return false;
@@ -1341,8 +1341,8 @@ bool WebAssemblyFastISel::selectRet(const Instruction *I) {
13411341
case MVT::v2f64:
13421342
Opc = WebAssembly::RETURN_v2f64;
13431343
break;
1344-
case MVT::ExceptRef:
1345-
Opc = WebAssembly::RETURN_EXCEPT_REF;
1344+
case MVT::exnref:
1345+
Opc = WebAssembly::RETURN_EXNREF;
13461346
break;
13471347
default:
13481348
return false;

lib/Target/WebAssembly/WebAssemblyInstrCall.td

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ defm "" : CALL<i32, I32, "i32.">;
5959
defm "" : CALL<i64, I64, "i64.">;
6060
defm "" : CALL<f32, F32, "f32.">;
6161
defm "" : CALL<f64, F64, "f64.">;
62-
defm "" : CALL<ExceptRef, EXCEPT_REF, "except_ref.", [HasExceptionHandling]>;
62+
defm "" : CALL<exnref, EXNREF, "exnref.", [HasExceptionHandling]>;
6363
defm "" : CALL<v16i8, V128, "v128.", [HasSIMD128]>;
6464
defm "" : CALL<v8i16, V128, "v128.", [HasSIMD128]>;
6565
defm "" : CALL<v4i32, V128, "v128.", [HasSIMD128]>;
@@ -139,9 +139,8 @@ def : Pat<(v4f32 (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))),
139139
(CALL_v4f32 tglobaladdr:$callee)>, Requires<[HasSIMD128]>;
140140
def : Pat<(v2f64 (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))),
141141
(CALL_v2f64 tglobaladdr:$callee)>, Requires<[HasSIMD128]>;
142-
def : Pat<(ExceptRef
143-
(WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))),
144-
(CALL_ExceptRef tglobaladdr:$callee)>,
142+
def : Pat<(exnref (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))),
143+
(CALL_exnref tglobaladdr:$callee)>,
145144
Requires<[HasExceptionHandling]>;
146145
def : Pat<(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee)),
147146
(CALL_VOID tglobaladdr:$callee)>;
@@ -169,9 +168,8 @@ def : Pat<(v4f32 (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))),
169168
(CALL_v4f32 texternalsym:$callee)>, Requires<[HasSIMD128]>;
170169
def : Pat<(v2f64 (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))),
171170
(CALL_v2f64 texternalsym:$callee)>, Requires<[HasSIMD128]>;
172-
def : Pat<(ExceptRef
173-
(WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))),
174-
(CALL_ExceptRef texternalsym:$callee)>,
171+
def : Pat<(exnref (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))),
172+
(CALL_exnref texternalsym:$callee)>,
175173
Requires<[HasExceptionHandling]>;
176174
def : Pat<(WebAssemblycall0 (WebAssemblywrapper texternalsym:$callee)),
177175
(CALL_VOID texternalsym:$callee)>;

0 commit comments

Comments
 (0)