Index: lld/trunk/wasm/WriterUtils.cpp =================================================================== --- lld/trunk/wasm/WriterUtils.cpp +++ lld/trunk/wasm/WriterUtils.cpp @@ -182,8 +182,8 @@ return "f64"; case ValType::V128: return "v128"; - case ValType::EXCEPT_REF: - return "except_ref"; + case ValType::EXNREF: + return "exnref"; } llvm_unreachable("Invalid wasm::ValType"); } Index: llvm/trunk/include/llvm/BinaryFormat/Wasm.h =================================================================== --- llvm/trunk/include/llvm/BinaryFormat/Wasm.h +++ llvm/trunk/include/llvm/BinaryFormat/Wasm.h @@ -224,7 +224,7 @@ WASM_TYPE_F64 = 0x7C, WASM_TYPE_V128 = 0x7B, WASM_TYPE_FUNCREF = 0x70, - WASM_TYPE_EXCEPT_REF = 0x68, + WASM_TYPE_EXNREF = 0x68, WASM_TYPE_FUNC = 0x60, WASM_TYPE_NORESULT = 0x40, // for blocks with no result values }; @@ -332,7 +332,7 @@ F32 = WASM_TYPE_F32, F64 = WASM_TYPE_F64, V128 = WASM_TYPE_V128, - EXCEPT_REF = WASM_TYPE_EXCEPT_REF, + EXNREF = WASM_TYPE_EXNREF, }; struct WasmSignature { Index: llvm/trunk/include/llvm/CodeGen/ValueTypes.td =================================================================== --- llvm/trunk/include/llvm/CodeGen/ValueTypes.td +++ llvm/trunk/include/llvm/CodeGen/ValueTypes.td @@ -160,7 +160,7 @@ def FlagVT : ValueType<0 , 126>; // Pre-RA sched glue def isVoid : ValueType<0 , 127>; // Produces no value def untyped: ValueType<8 , 128>; // Produces an untyped value -def ExceptRef: ValueType<0, 129>; // WebAssembly's except_ref type +def exnref: ValueType<0, 129>; // WebAssembly's exnref type def token : ValueType<0 , 248>; // TokenTy def MetadataVT: ValueType<0, 249>; // Metadata Index: llvm/trunk/include/llvm/Support/MachineValueType.h =================================================================== --- llvm/trunk/include/llvm/Support/MachineValueType.h +++ llvm/trunk/include/llvm/Support/MachineValueType.h @@ -206,7 +206,7 @@ // unspecified type. The register class // will be determined by the opcode. - ExceptRef = 129, // WebAssembly's except_ref type + exnref = 129, // WebAssembly's exnref type FIRST_VALUETYPE = 1, // This is always the beginning of the list. LAST_VALUETYPE = 130, // This always remains at the end of the list. @@ -811,7 +811,7 @@ case v1024f32: return 32768; case v2048i32: case v2048f32: return 65536; - case ExceptRef: return 0; // opaque type + case exnref: return 0; // opaque type } } Index: llvm/trunk/lib/CodeGen/ValueTypes.cpp =================================================================== --- llvm/trunk/lib/CodeGen/ValueTypes.cpp +++ llvm/trunk/lib/CodeGen/ValueTypes.cpp @@ -207,7 +207,7 @@ case MVT::v8f64: return "v8f64"; case MVT::Metadata:return "Metadata"; case MVT::Untyped: return "Untyped"; - case MVT::ExceptRef: return "ExceptRef"; + case MVT::exnref : return "exnref"; } } Index: llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -308,8 +308,8 @@ Type == "i32x4" || Type == "i64x2" || Type == "f32x4" || Type == "f64x2") return wasm::ValType::V128; - if (Type == "except_ref") - return wasm::ValType::EXCEPT_REF; + if (Type == "exnref") + return wasm::ValType::EXNREF; return Optional(); } @@ -320,7 +320,7 @@ .Case("f32", WebAssembly::ExprType::F32) .Case("f64", WebAssembly::ExprType::F64) .Case("v128", WebAssembly::ExprType::V128) - .Case("except_ref", WebAssembly::ExprType::ExceptRef) + .Case("exnref", WebAssembly::ExprType::Exnref) .Case("void", WebAssembly::ExprType::Void) .Default(WebAssembly::ExprType::Invalid); } Index: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp +++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp @@ -282,8 +282,8 @@ return "funcref"; case wasm::WASM_TYPE_FUNC: return "func"; - case wasm::WASM_TYPE_EXCEPT_REF: - return "except_ref"; + case wasm::WASM_TYPE_EXNREF: + return "exnref"; case wasm::WASM_TYPE_NORESULT: return "void"; default: Index: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h =================================================================== --- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h +++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h @@ -130,7 +130,7 @@ F32 = 0x7D, F64 = 0x7C, V128 = 0x7B, - ExceptRef = 0x68, + Exnref = 0x68, Invalid = 0x00 }; @@ -403,8 +403,8 @@ case WebAssembly::COPY_F64_S: case WebAssembly::COPY_V128: case WebAssembly::COPY_V128_S: - case WebAssembly::COPY_EXCEPT_REF: - case WebAssembly::COPY_EXCEPT_REF_S: + case WebAssembly::COPY_EXNREF: + case WebAssembly::COPY_EXNREF_S: return true; default: return false; @@ -453,8 +453,8 @@ case WebAssembly::CALL_v4f32_S: case WebAssembly::CALL_v2f64: case WebAssembly::CALL_v2f64_S: - case WebAssembly::CALL_ExceptRef: - case WebAssembly::CALL_ExceptRef_S: + case WebAssembly::CALL_exnref: + case WebAssembly::CALL_exnref_S: case WebAssembly::RET_CALL: case WebAssembly::RET_CALL_S: return true; @@ -487,8 +487,8 @@ case WebAssembly::CALL_INDIRECT_v4f32_S: case WebAssembly::CALL_INDIRECT_v2f64: case WebAssembly::CALL_INDIRECT_v2f64_S: - case WebAssembly::CALL_INDIRECT_ExceptRef: - case WebAssembly::CALL_INDIRECT_ExceptRef_S: + case WebAssembly::CALL_INDIRECT_exnref: + case WebAssembly::CALL_INDIRECT_exnref_S: case WebAssembly::RET_CALL_INDIRECT: case WebAssembly::RET_CALL_INDIRECT_S: return true; @@ -530,8 +530,8 @@ case WebAssembly::CALL_v4f32_S: case WebAssembly::CALL_v2f64: case WebAssembly::CALL_v2f64_S: - case WebAssembly::CALL_ExceptRef: - case WebAssembly::CALL_ExceptRef_S: + case WebAssembly::CALL_exnref: + case WebAssembly::CALL_exnref_S: case WebAssembly::CALL_INDIRECT_i32: case WebAssembly::CALL_INDIRECT_i32_S: case WebAssembly::CALL_INDIRECT_i64: @@ -552,8 +552,8 @@ case WebAssembly::CALL_INDIRECT_v4f32_S: case WebAssembly::CALL_INDIRECT_v2f64: case WebAssembly::CALL_INDIRECT_v2f64_S: - case WebAssembly::CALL_INDIRECT_ExceptRef: - case WebAssembly::CALL_INDIRECT_ExceptRef_S: + case WebAssembly::CALL_INDIRECT_exnref: + case WebAssembly::CALL_INDIRECT_exnref_S: return 1; default: llvm_unreachable("Not a call instruction"); Index: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp +++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp @@ -146,8 +146,8 @@ case MVT::v4f32: case MVT::v2f64: return wasm::ValType::V128; - case MVT::ExceptRef: - return wasm::ValType::EXCEPT_REF; + case MVT::exnref: + return wasm::ValType::EXNREF; default: llvm_unreachable("unexpected type"); } Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp @@ -308,7 +308,7 @@ // Add the BLOCK. - // 'br_on_exn' extracts except_ref object and pushes variable number of values + // 'br_on_exn' extracts exnref object and pushes variable number of values // depending on its tag. For C++ exception, its a single i32 value, and the // generated code will be in the form of: // block i32 @@ -766,11 +766,11 @@ // Note that the new wrapping block/end_block will be generated later in // placeBlockMarker. // - // TODO Currently local.set and local.gets are generated to move except_ref - // value created by catches. That's because we don't support yielding values - // from a block in LLVM machine IR yet, even though it is supported by wasm. - // Delete unnecessary local.get/local.sets once yielding values from a block - // is supported. The full EH spec requires multi-value support to do this, but + // TODO Currently local.set and local.gets are generated to move exnref value + // created by catches. That's because we don't support yielding values from a + // block in LLVM machine IR yet, even though it is supported by wasm. Delete + // unnecessary local.get/local.sets once yielding values from a block is + // supported. The full EH spec requires multi-value support to do this, but // for C++ we don't yet need it because we only throw a single i32. // // --- @@ -834,7 +834,7 @@ DenseMap> UnwindDestToTryRanges; // In new CFG, DenseMap> BrDestToTryRanges; - // In new CFG, + // In new CFG, DenseMap BrDestToExnReg; // Gather possibly throwing calls (i.e., previously invokes) whose current @@ -936,8 +936,7 @@ // of the function with a local.get and a rethrow instruction. if (NeedAppendixBlock) { auto *AppendixBB = getAppendixBlock(MF); - unsigned ExnReg = - MRI.createVirtualRegister(&WebAssembly::EXCEPT_REFRegClass); + unsigned ExnReg = MRI.createVirtualRegister(&WebAssembly::EXNREFRegClass); BuildMI(AppendixBB, DebugLoc(), TII.get(WebAssembly::RETHROW)) .addReg(ExnReg); // These instruction ranges should branch to this appendix BB. @@ -1225,8 +1224,8 @@ case MVT::v2f64: RetType = WebAssembly::ExprType::V128; break; - case MVT::ExceptRef: - RetType = WebAssembly::ExprType::ExceptRef; + case MVT::exnref: + RetType = WebAssembly::ExprType::Exnref; break; default: llvm_unreachable("unexpected return type"); Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp @@ -85,8 +85,8 @@ return CALL_INDIRECT_v4f32; case PCALL_INDIRECT_v2f64: return CALL_INDIRECT_v2f64; - case PCALL_INDIRECT_ExceptRef: - return CALL_INDIRECT_ExceptRef; + case PCALL_INDIRECT_exnref: + return CALL_INDIRECT_exnref; case PRET_CALL_INDIRECT: return RET_CALL_INDIRECT; default: Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp @@ -90,8 +90,8 @@ return WebAssembly::DROP_F64; if (RC == &WebAssembly::V128RegClass) return WebAssembly::DROP_V128; - if (RC == &WebAssembly::EXCEPT_REFRegClass) - return WebAssembly::DROP_EXCEPT_REF; + if (RC == &WebAssembly::EXNREFRegClass) + return WebAssembly::DROP_EXNREF; llvm_unreachable("Unexpected register class"); } @@ -107,8 +107,8 @@ return WebAssembly::LOCAL_GET_F64; if (RC == &WebAssembly::V128RegClass) return WebAssembly::LOCAL_GET_V128; - if (RC == &WebAssembly::EXCEPT_REFRegClass) - return WebAssembly::LOCAL_GET_EXCEPT_REF; + if (RC == &WebAssembly::EXNREFRegClass) + return WebAssembly::LOCAL_GET_EXNREF; llvm_unreachable("Unexpected register class"); } @@ -124,8 +124,8 @@ return WebAssembly::LOCAL_SET_F64; if (RC == &WebAssembly::V128RegClass) return WebAssembly::LOCAL_SET_V128; - if (RC == &WebAssembly::EXCEPT_REFRegClass) - return WebAssembly::LOCAL_SET_EXCEPT_REF; + if (RC == &WebAssembly::EXNREFRegClass) + return WebAssembly::LOCAL_SET_EXNREF; llvm_unreachable("Unexpected register class"); } @@ -141,8 +141,8 @@ return WebAssembly::LOCAL_TEE_F64; if (RC == &WebAssembly::V128RegClass) return WebAssembly::LOCAL_TEE_V128; - if (RC == &WebAssembly::EXCEPT_REFRegClass) - return WebAssembly::LOCAL_TEE_EXCEPT_REF; + if (RC == &WebAssembly::EXNREFRegClass) + return WebAssembly::LOCAL_TEE_EXNREF; llvm_unreachable("Unexpected register class"); } @@ -158,8 +158,8 @@ return MVT::f64; if (RC == &WebAssembly::V128RegClass) return MVT::v16i8; - if (RC == &WebAssembly::EXCEPT_REFRegClass) - return MVT::ExceptRef; + if (RC == &WebAssembly::EXNREFRegClass) + return MVT::exnref; llvm_unreachable("unrecognized register class"); } Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp @@ -129,7 +129,7 @@ case MVT::i64: case MVT::f32: case MVT::f64: - case MVT::ExceptRef: + case MVT::exnref: return VT; case MVT::f16: return MVT::f32; @@ -698,9 +698,9 @@ Opc = WebAssembly::ARGUMENT_v2f64; RC = &WebAssembly::V128RegClass; break; - case MVT::ExceptRef: - Opc = WebAssembly::ARGUMENT_ExceptRef; - RC = &WebAssembly::EXCEPT_REFRegClass; + case MVT::exnref: + Opc = WebAssembly::ARGUMENT_exnref; + RC = &WebAssembly::EXNREFRegClass; break; default: return false; @@ -815,10 +815,10 @@ : WebAssembly::PCALL_INDIRECT_v2f64; ResultReg = createResultReg(&WebAssembly::V128RegClass); break; - case MVT::ExceptRef: - Opc = IsDirect ? WebAssembly::CALL_ExceptRef - : WebAssembly::PCALL_INDIRECT_ExceptRef; - ResultReg = createResultReg(&WebAssembly::EXCEPT_REFRegClass); + case MVT::exnref: + Opc = IsDirect ? WebAssembly::CALL_exnref + : WebAssembly::PCALL_INDIRECT_exnref; + ResultReg = createResultReg(&WebAssembly::EXNREFRegClass); break; default: return false; @@ -921,9 +921,9 @@ Opc = WebAssembly::SELECT_F64; RC = &WebAssembly::F64RegClass; break; - case MVT::ExceptRef: - Opc = WebAssembly::SELECT_EXCEPT_REF; - RC = &WebAssembly::EXCEPT_REFRegClass; + case MVT::exnref: + Opc = WebAssembly::SELECT_EXNREF; + RC = &WebAssembly::EXNREFRegClass; break; default: return false; @@ -1341,8 +1341,8 @@ case MVT::v2f64: Opc = WebAssembly::RETURN_v2f64; break; - case MVT::ExceptRef: - Opc = WebAssembly::RETURN_EXCEPT_REF; + case MVT::exnref: + Opc = WebAssembly::RETURN_EXNREF; break; default: return false; Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td @@ -59,7 +59,7 @@ defm "" : CALL; defm "" : CALL; defm "" : CALL; -defm "" : CALL; +defm "" : CALL; defm "" : CALL; defm "" : CALL; defm "" : CALL; @@ -139,9 +139,8 @@ (CALL_v4f32 tglobaladdr:$callee)>, Requires<[HasSIMD128]>; def : Pat<(v2f64 (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))), (CALL_v2f64 tglobaladdr:$callee)>, Requires<[HasSIMD128]>; -def : Pat<(ExceptRef - (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))), - (CALL_ExceptRef tglobaladdr:$callee)>, +def : Pat<(exnref (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))), + (CALL_exnref tglobaladdr:$callee)>, Requires<[HasExceptionHandling]>; def : Pat<(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee)), (CALL_VOID tglobaladdr:$callee)>; @@ -169,9 +168,8 @@ (CALL_v4f32 texternalsym:$callee)>, Requires<[HasSIMD128]>; def : Pat<(v2f64 (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))), (CALL_v2f64 texternalsym:$callee)>, Requires<[HasSIMD128]>; -def : Pat<(ExceptRef - (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))), - (CALL_ExceptRef texternalsym:$callee)>, +def : Pat<(exnref (WebAssemblycall1 (WebAssemblywrapper texternalsym:$callee))), + (CALL_exnref texternalsym:$callee)>, Requires<[HasExceptionHandling]>; def : Pat<(WebAssemblycall0 (WebAssemblywrapper texternalsym:$callee)), (CALL_VOID texternalsym:$callee)>; Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrControl.td =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrControl.td +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrControl.td @@ -114,7 +114,7 @@ defm "": RETURN; defm "": RETURN; defm "": RETURN; - defm "": RETURN; + defm "": RETURN; defm "": SIMD_RETURN; defm "": SIMD_RETURN; defm "": SIMD_RETURN; @@ -144,8 +144,8 @@ (outs), (ins event_op:$tag), [(WebAssemblythrow (WebAssemblywrapper texternalsym:$tag))], "throw \t$tag", "throw \t$tag", 0x08>; -defm RETHROW : I<(outs), (ins EXCEPT_REF:$exn), (outs), (ins), - [], "rethrow \t$exn", "rethrow", 0x09>; +defm RETHROW : I<(outs), (ins EXNREF:$exn), (outs), (ins), [], + "rethrow \t$exn", "rethrow", 0x09>; // Pseudo instruction to be the lowering target of int_wasm_rethrow_in_catch // intrinsic. Will be converted to the real rethrow instruction later. let isPseudo = 1 in @@ -161,15 +161,15 @@ // Catching an exception: catch / extract_exception let hasCtrlDep = 1, hasSideEffects = 1 in -defm CATCH : I<(outs EXCEPT_REF:$dst), (ins), (outs), (ins), [], +defm CATCH : I<(outs EXNREF:$dst), (ins), (outs), (ins), [], "catch \t$dst", "catch", 0x07>; // Querying / extracing exception: br_on_exn -// br_on_exn queries an except_ref to see if it matches the corresponding -// exception tag index. If true it branches to the given label and pushes the +// br_on_exn queries an exnref to see if it matches the corresponding exception +// tag index. If true it branches to the given label and pushes the // corresponding argument values of the exception onto the stack. let isBranch = 1, isTerminator = 1, hasCtrlDep = 1 in -defm BR_ON_EXN : I<(outs), (ins bb_op:$dst, event_op:$tag, EXCEPT_REF:$exn), +defm BR_ON_EXN : I<(outs), (ins bb_op:$dst, event_op:$tag, EXNREF:$exn), (outs), (ins bb_op:$dst, event_op:$tag), [], "br_on_exn \t$dst, $tag, $exn", "br_on_exn \t$dst, $tag", 0x0a>; Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrExceptRef.td =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrExceptRef.td +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrExceptRef.td @@ -1,26 +0,0 @@ -// WebAssemblyInstrExceptRef.td-WebAssembly except_ref codegen --*- tablegen -*- -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -/// -/// \file -/// WebAssembly except_ref operand code-gen constructs. -/// -//===----------------------------------------------------------------------===// - -defm SELECT_EXCEPT_REF : I<(outs EXCEPT_REF:$dst), - (ins EXCEPT_REF:$lhs, EXCEPT_REF:$rhs, I32:$cond), - (outs), (ins), - [(set EXCEPT_REF:$dst, - (select I32:$cond, EXCEPT_REF:$lhs, - EXCEPT_REF:$rhs))], - "except_ref.select\t$dst, $lhs, $rhs, $cond", - "except_ref.select", 0x1b>; - -def : Pat<(select (i32 (setne I32:$cond, 0)), EXCEPT_REF:$lhs, EXCEPT_REF:$rhs), - (SELECT_EXCEPT_REF EXCEPT_REF:$lhs, EXCEPT_REF:$rhs, I32:$cond)>; -def : Pat<(select (i32 (seteq I32:$cond, 0)), EXCEPT_REF:$lhs, EXCEPT_REF:$rhs), - (SELECT_EXCEPT_REF EXCEPT_REF:$rhs, EXCEPT_REF:$lhs, I32:$cond)>; Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp @@ -192,7 +192,7 @@ MachineFunction &MF = *MBB.getParent(); auto &MRI = MF.getRegInfo(); bool IsBrOnExn = Cond[1].isReg() && MRI.getRegClass(Cond[1].getReg()) == - &WebAssembly::EXCEPT_REFRegClass; + &WebAssembly::EXNREFRegClass; if (Cond[0].getImm()) { if (IsBrOnExn) { @@ -222,7 +222,7 @@ MachineFunction &MF = *Cond[1].getParent()->getParent()->getParent(); auto &MRI = MF.getRegInfo(); if (Cond[1].isReg() && - MRI.getRegClass(Cond[1].getReg()) == &WebAssembly::EXCEPT_REFRegClass) + MRI.getRegClass(Cond[1].getReg()) == &WebAssembly::EXNREFRegClass) return true; Cond.front() = MachineOperand::CreateImm(!Cond.front().getImm()); Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.td @@ -224,7 +224,7 @@ defm "": ARGUMENT; defm "": ARGUMENT; defm "": ARGUMENT; -defm "": ARGUMENT; +defm "": ARGUMENT; // local.get and local.set are not generated by instruction selection; they // are implied by virtual register uses and defs. @@ -294,7 +294,7 @@ defm "" : LOCAL; defm "" : LOCAL; defm "" : LOCAL, Requires<[HasSIMD128]>; -defm "" : LOCAL, Requires<[HasExceptionHandling]>; +defm "" : LOCAL, Requires<[HasExceptionHandling]>; let isMoveImm = 1, isAsCheapAsAMove = 1, isReMaterializable = 1 in { defm CONST_I32 : I<(outs I32:$res), (ins i32imm_op:$imm), @@ -345,5 +345,5 @@ include "WebAssemblyInstrFloat.td" include "WebAssemblyInstrAtomics.td" include "WebAssemblyInstrSIMD.td" -include "WebAssemblyInstrExceptRef.td" +include "WebAssemblyInstrRef.td" include "WebAssemblyInstrBulkMemory.td" Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrRef.td =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrRef.td +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrRef.td @@ -0,0 +1,25 @@ +// WebAssemblyInstrRef.td - WebAssembly reference type codegen --*- tablegen -*- +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// WebAssembly refence type operand codegen constructs. +/// +//===----------------------------------------------------------------------===// + +defm SELECT_EXNREF : I<(outs EXNREF:$dst), + (ins EXNREF:$lhs, EXNREF:$rhs, I32:$cond), + (outs), (ins), + [(set EXNREF:$dst, + (select I32:$cond, EXNREF:$lhs, EXNREF:$rhs))], + "exnref.select\t$dst, $lhs, $rhs, $cond", + "exnref.select", 0x1b>; + +def : Pat<(select (i32 (setne I32:$cond, 0)), EXNREF:$lhs, EXNREF:$rhs), + (SELECT_EXNREF EXNREF:$lhs, EXNREF:$rhs, I32:$cond)>; +def : Pat<(select (i32 (seteq I32:$cond, 0)), EXNREF:$lhs, EXNREF:$rhs), + (SELECT_EXNREF EXNREF:$rhs, EXNREF:$lhs, I32:$cond)>; Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp @@ -131,8 +131,7 @@ auto InsertPos = MBB.begin(); if (InsertPos->isEHLabel()) // EH pad starts with an EH label ++InsertPos; - unsigned DstReg = - MRI.createVirtualRegister(&WebAssembly::EXCEPT_REFRegClass); + unsigned DstReg = MRI.createVirtualRegister(&WebAssembly::EXNREFRegClass); BuildMI(MBB, InsertPos, MBB.begin()->getDebugLoc(), TII.get(WebAssembly::CATCH), DstReg); } @@ -209,23 +208,23 @@ } // Wasm uses 'br_on_exn' instruction to check the tag of an exception. It takes -// except_ref type object returned by 'catch', and branches to the destination -// if it matches a given tag. We currently use __cpp_exception symbol to -// represent the tag for all C++ exceptions. +// exnref type object returned by 'catch', and branches to the destination if it +// matches a given tag. We currently use __cpp_exception symbol to represent the +// tag for all C++ exceptions. // // block $l (result i32) // ... -// ;; except_ref $e is on the stack at this point +// ;; exnref $e is on the stack at this point // br_on_exn $l $e ;; branch to $l with $e's arguments // ... // end // ;; Here we expect the extracted values are on top of the wasm value stack // ... Handle exception using values ... // -// br_on_exn takes an except_ref object and branches if it matches the given -// tag. There can be multiple br_on_exn instructions if we want to match for -// another tag, but for now we only test for __cpp_exception tag, and if it does -// not match, i.e., it is a foreign exception, we rethrow it. +// br_on_exn takes an exnref object and branches if it matches the given tag. +// There can be multiple br_on_exn instructions if we want to match for another +// tag, but for now we only test for __cpp_exception tag, and if it does not +// match, i.e., it is a foreign exception, we rethrow it. // // In the destination BB that's the target of br_on_exn, extracted exception // values (in C++'s case a single i32, which represents an exception pointer) @@ -279,13 +278,13 @@ // - Before: // ehpad: - // %exnref:except_ref = catch + // %exnref:exnref = catch // %exn:i32 = extract_exception // ... use exn ... // // - After: // ehpad: - // %exnref:except_ref = catch + // %exnref:exnref = catch // br_on_exn %thenbb, $__cpp_exception, %exnref // br %elsebb // elsebb: @@ -317,14 +316,14 @@ // // - Before: // ehpad: - // %exnref:except_ref = catch + // %exnref:exnref = catch // %exn:i32 = extract_exception // call @__clang_call_terminate(%exn) // unreachable // // - After: // ehpad: - // %exnref:except_ref = catch + // %exnref:exnref = catch // br_on_exn %thenbb, $__cpp_exception, %exnref // br %elsebb // elsebb: Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp @@ -834,9 +834,9 @@ // entering blocks, which is a part of multi-value proposal. // // Once we support live-in values of wasm blocks, this can be: - // catch ; push except_ref value onto stack - // block except_ref -> i32 - // br_on_exn $__cpp_exception ; pop the except_ref value + // catch ; push exnref value onto stack + // block exnref -> i32 + // br_on_exn $__cpp_exception ; pop the exnref value // end_block // // But because we don't support it yet, the catch instruction's dst Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegisterInfo.td =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegisterInfo.td +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegisterInfo.td @@ -43,7 +43,7 @@ def V128_0: WebAssemblyReg<"%v128">; -def EXCEPT_REF_0 : WebAssemblyReg<"%except_ref.0">; +def EXNREF_0 : WebAssemblyReg<"%exnref.0">; // The value stack "register". This is an opaque entity which serves to order // uses and defs that must remain in LIFO order. @@ -64,4 +64,4 @@ def F64 : WebAssemblyRegClass<[f64], 64, (add F64_0)>; def V128 : WebAssemblyRegClass<[v4f32, v2f64, v2i64, v4i32, v16i8, v8i16], 128, (add V128_0)>; -def EXCEPT_REF : WebAssemblyRegClass<[ExceptRef], 0, (add EXCEPT_REF_0)>; +def EXNREF : WebAssemblyRegClass<[exnref], 0, (add EXNREF_0)>; Index: llvm/trunk/test/CodeGen/WebAssembly/exception.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/exception.ll +++ llvm/trunk/test/CodeGen/WebAssembly/exception.ll @@ -31,11 +31,11 @@ ; CHECK: global.get ${{.+}}=, __stack_pointer ; CHECK: try ; CHECK: call foo -; CHECK: catch $[[EXCEPT_REF:[0-9]+]]= +; CHECK: catch $[[EXNREF:[0-9]+]]= ; CHECK: global.set __stack_pointer ; CHECK: block i32 -; CHECK: br_on_exn 0, __cpp_exception, $[[EXCEPT_REF]] -; CHECK: rethrow $[[EXCEPT_REF]] +; CHECK: br_on_exn 0, __cpp_exception, $[[EXNREF]] +; CHECK: rethrow $[[EXNREF]] ; CHECK: end_block ; CHECK: extract_exception $[[EXN:[0-9]+]]= ; CHECK-DAG: i32.store __wasm_lpad_context @@ -47,7 +47,7 @@ ; CHECK: call __cxa_end_catch ; CHECK: br 1 ; CHECK: end_block -; CHECK: rethrow $[[EXCEPT_REF]] +; CHECK: rethrow $[[EXNREF]] ; CHECK: end_try define void @test_catch() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) { entry: @@ -92,10 +92,10 @@ ; CHECK-LABEL: test_cleanup: ; CHECK: try ; CHECK: call foo -; CHECK: catch $[[EXCEPT_REF:[0-9]+]]= +; CHECK: catch $[[EXNREF:[0-9]+]]= ; CHECK: global.set __stack_pointer ; CHECK: i32.call $drop=, _ZN4TempD2Ev -; CHECK: rethrow $[[EXCEPT_REF]] +; CHECK: rethrow $[[EXNREF]] ; CHECK: end_try define void @test_cleanup() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) { entry: Index: llvm/trunk/test/MC/Disassembler/WebAssembly/wasm.txt =================================================================== --- llvm/trunk/test/MC/Disassembler/WebAssembly/wasm.txt +++ llvm/trunk/test/MC/Disassembler/WebAssembly/wasm.txt @@ -23,7 +23,7 @@ 0x11 0x80 0x01 0x00 # CHECK: call 0 -# CHECK-NOT: except_ref.call 0 +# CHECK-NOT: exnref.call 0 0x10 0x00 # CHECK: local.get 128 Index: llvm/trunk/test/MC/WebAssembly/basic-assembly.s =================================================================== --- llvm/trunk/test/MC/WebAssembly/basic-assembly.s +++ llvm/trunk/test/MC/WebAssembly/basic-assembly.s @@ -70,7 +70,7 @@ # TODO: enable once instruction has been added. #i32x4.trunc_sat_f32x4_s i32.trunc_f32_s - try except_ref + try exnref i32.atomic.load 0 atomic.notify 0 .LBB0_3: @@ -172,7 +172,7 @@ # CHECK-NEXT: end_if # CHECK-NEXT: f32x4.add # CHECK-NEXT: i32.trunc_f32_s -# CHECK-NEXT: try except_ref +# CHECK-NEXT: try exnref # CHECK-NEXT: i32.atomic.load 0 # CHECK-NEXT: atomic.notify 0 # CHECK-NEXT: .LBB0_3: Index: llvm/trunk/test/MC/WebAssembly/objdump.s =================================================================== --- llvm/trunk/test/MC/WebAssembly/objdump.s +++ llvm/trunk/test/MC/WebAssembly/objdump.s @@ -9,7 +9,7 @@ test1: .functype test1 (i32, i64) -> (i32) - .local i32, i64, except_ref + .local i32, i64, exnref local.get 3 end_function @@ -21,6 +21,6 @@ # CHECK-NEXT: 9: 20 02 local.get 2 # CHECK-NEXT: b: 0b end # CHECK-LABEL: test1: -# CHECK-NEXT: .local i32, i64, except_ref +# CHECK-NEXT: .local i32, i64, exnref # CHECK-NEXT: 14: 20 03 local.get 3 # CHECK-NEXT: 16: 0b end Index: llvm/trunk/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp =================================================================== --- llvm/trunk/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp +++ llvm/trunk/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp @@ -100,14 +100,14 @@ ; predecessors: %bb.0 successors: %bb.3, %bb.9 liveins: $value_stack - %0:except_ref = CATCH implicit-def $arguments + %0:exnref = CATCH implicit-def $arguments CLEANUPRET implicit-def dead $arguments bb.3 (landing-pad): ; predecessors: %bb.2 successors: %bb.4, %bb.6 liveins: $value_stack - %1:except_ref = CATCH implicit-def $arguments + %1:exnref = CATCH implicit-def $arguments BR_IF %bb.4, %58:i32, implicit-def $arguments, implicit-def $value_stack, implicit $value_stack BR %bb.6, implicit-def $arguments @@ -138,13 +138,13 @@ ; predecessors: %bb.4 successors: %bb.9 liveins: $value_stack - %2:except_ref = CATCH implicit-def $arguments + %2:exnref = CATCH implicit-def $arguments CLEANUPRET implicit-def dead $arguments bb.9 (landing-pad): ; predecessors: %bb.2, %bb.6, %bb.8 liveins: $value_stack - %3:except_ref = CATCH implicit-def $arguments + %3:exnref = CATCH implicit-def $arguments CLEANUPRET implicit-def dead $arguments bb.10: @@ -257,7 +257,7 @@ ; predecessors: %bb.0 successors: %bb.2, %bb.8 liveins: $value_stack - %0:except_ref = CATCH implicit-def $arguments + %0:exnref = CATCH implicit-def $arguments BR_IF %bb.2, %32:i32, implicit-def $arguments, implicit-def $value_stack, implicit $value_stack BR %bb.8, implicit-def $arguments @@ -271,7 +271,7 @@ ; predecessors: %bb.2 successors: %bb.4, %bb.6 liveins: $value_stack - %1:except_ref = CATCH implicit-def $arguments + %1:exnref = CATCH implicit-def $arguments BR_IF %bb.4, %43:i32, implicit-def $arguments, implicit-def $value_stack, implicit $value_stack BR %bb.6, implicit-def $arguments @@ -313,13 +313,13 @@ ; predecessors: %bb.4 successors: %bb.11 liveins: $value_stack - %2:except_ref = CATCH implicit-def $arguments + %2:exnref = CATCH implicit-def $arguments CLEANUPRET implicit-def dead $arguments bb.11 (landing-pad): ; predecessors: %bb.2, %bb.6, %bb.10 liveins: $value_stack - %3:except_ref = CATCH implicit-def $arguments + %3:exnref = CATCH implicit-def $arguments CLEANUPRET implicit-def dead $arguments bb.12: Index: llvm/trunk/utils/TableGen/CodeGenTarget.cpp =================================================================== --- llvm/trunk/utils/TableGen/CodeGenTarget.cpp +++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp @@ -191,7 +191,7 @@ case MVT::iPTR: return "MVT::iPTR"; case MVT::iPTRAny: return "MVT::iPTRAny"; case MVT::Untyped: return "MVT::Untyped"; - case MVT::ExceptRef: return "MVT::ExceptRef"; + case MVT::exnref: return "MVT::exnref"; default: llvm_unreachable("ILLEGAL VALUE TYPE!"); } }