Index: lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -42,11 +42,12 @@ class WebAssemblyAsmPrinter final : public AsmPrinter { const WebAssemblyInstrInfo *TII; + const MachineRegisterInfo *MRI; unsigned NumArgs; public: WebAssemblyAsmPrinter(TargetMachine &TM, std::unique_ptr Streamer) - : AsmPrinter(TM, std::move(Streamer)), TII(nullptr) {} + : AsmPrinter(TM, std::move(Streamer)), TII(nullptr), MRI(nullptr) {} private: const char *getPassName() const override { @@ -64,6 +65,7 @@ bool runOnMachineFunction(MachineFunction &MF) override { const auto &Subtarget = MF.getSubtarget(); TII = Subtarget.getInstrInfo(); + MRI = &MF.getRegInfo(); NumArgs = MF.getInfo()->getNumArguments(); return AsmPrinter::runOnMachineFunction(MF); } @@ -78,10 +80,11 @@ void EmitInstruction(const MachineInstr *MI) override; + std::string getRegTypeName(unsigned RegNo) const; static std::string toString(const APFloat &APF); const char *toString(Type *Ty) const; - std::string regToString(unsigned RegNo); - std::string argToString(unsigned ArgNo); + std::string regToString(const MachineOperand &MO); + std::string argToString(const MachineOperand &MO); }; } // end anonymous namespace @@ -90,19 +93,33 @@ // Helpers. //===----------------------------------------------------------------------===// -// Untyped, lower-case version of the opcode's name matching the names -// WebAssembly opcodes are expected to have. The tablegen names are uppercase -// and suffixed with their type (after an underscore). -static SmallString<32> OpcodeName(const WebAssemblyInstrInfo *TII, - const MachineInstr *MI) { +// Operand type (if any), followed by the lower-case version of the opcode's +// name matching the names WebAssembly opcodes are expected to have. The +// tablegen names are uppercase and suffixed with their type (after an +// underscore). +static std::string OpcodeName(const WebAssemblyInstrInfo *TII, + const MachineInstr *MI) { std::string N(StringRef(TII->getName(MI->getOpcode())).lower()); - std::string::size_type End = N.rfind('_'); - End = std::string::npos == End ? N.length() : End; - return SmallString<32>(&N[0], &N[End]); + std::string::size_type Len = N.length(); + std::string::size_type Under = N.rfind('_'); + bool HasType = std::string::npos != Under; + std::string::size_type NameEnd = HasType ? Under : Len; + std::string Name(&N[0], &N[NameEnd]); + return HasType ? (std::string(&N[NameEnd + 1], &N[Len]) + '.' + Name) : Name; } static std::string toSymbol(StringRef S) { return ("$" + S).str(); } +std::string WebAssemblyAsmPrinter::getRegTypeName(unsigned RegNo) const { + const TargetRegisterClass *TRC = MRI->getRegClass(RegNo); + for (MVT T : {MVT::i32, MVT::i64, MVT::f32, MVT::f64}) + if (TRC->hasType(T)) + return EVT(T).getEVTString(); + DEBUG(errs() << "Unknown type for register number: " << RegNo); + llvm_unreachable("Unknown register type"); + return "?"; +} + std::string WebAssemblyAsmPrinter::toString(const APFloat &FP) { static const size_t BufBytes = 128; char buf[BufBytes]; @@ -120,19 +137,21 @@ return buf; } -std::string WebAssemblyAsmPrinter::regToString(unsigned RegNo) { +std::string WebAssemblyAsmPrinter::regToString(const MachineOperand &MO) { + unsigned RegNo = MO.getReg(); if (TargetRegisterInfo::isPhysicalRegister(RegNo)) return WebAssemblyInstPrinter::getRegisterName(RegNo); // WebAssembly arguments and local variables are in the same index space, and // there are no explicit varargs, so we just add the number of arguments to // the virtual register number to get the local variable number. - return '@' + utostr(TargetRegisterInfo::virtReg2Index(RegNo) + NumArgs); + return utostr(TargetRegisterInfo::virtReg2Index(RegNo) + NumArgs); } -std::string WebAssemblyAsmPrinter::argToString(unsigned ArgNo) { +std::string WebAssemblyAsmPrinter::argToString(const MachineOperand &MO) { + unsigned ArgNo = MO.getImm(); // Same as above, but we don't need to add NumArgs here. - return '@' + utostr(ArgNo); + return utostr(ArgNo); } const char *WebAssemblyAsmPrinter::toString(Type *Ty) const { @@ -189,26 +208,36 @@ void WebAssemblyAsmPrinter::EmitFunctionBodyStart() { const Function *F = MF->getFunction(); Type *Rt = F->getReturnType(); + SmallString<128> Str; + raw_svector_ostream OS(Str); + bool First = true; if (!Rt->isVoidTy() || !F->arg_empty()) { - SmallString<128> Str; - raw_svector_ostream OS(Str); - bool First = true; for (const Argument &A : F->args()) { - OS << (First ? "" : "\n") << "\t" - ".param " - << toString(A.getType()); + OS << (First ? "" : "\n") << "\t.param " << toString(A.getType()); First = false; } if (!Rt->isVoidTy()) { - OS << (First ? "" : "\n") << "\t" - ".result " - << toString(Rt); + OS << (First ? "" : "\n") << "\t.result " << toString(Rt); First = false; } - OutStreamer->EmitRawText(OS.str()); } + bool FirstVReg = true; + for (unsigned Idx = 0, IdxE = MRI->getNumVirtRegs(); Idx != IdxE; ++Idx) { + unsigned VReg = TargetRegisterInfo::index2VirtReg(Idx); + if (!MRI->use_empty(VReg)) { + if (FirstVReg) { + OS << (First ? "" : "\n") << "\t.local "; + First = false; + } + OS << (FirstVReg ? "" : ", ") << getRegTypeName(VReg); + FirstVReg = false; + } + } + + if (!First) + OutStreamer->EmitRawText(OS.str()); AsmPrinter::EmitFunctionBodyStart(); } @@ -225,7 +254,7 @@ switch (MI->getOpcode()) { case TargetOpcode::COPY: - OS << regToString(MI->getOperand(1).getReg()); + OS << "get_local " << regToString(MI->getOperand(1)); break; case WebAssembly::GLOBAL: // TODO: wasm64 @@ -235,7 +264,7 @@ case WebAssembly::ARGUMENT_I64: case WebAssembly::ARGUMENT_F32: case WebAssembly::ARGUMENT_F64: - OS << argToString(MI->getOperand(1).getImm()); + OS << "get_local " << argToString(MI->getOperand(1)); break; case WebAssembly::Immediate_I32: OS << "i32.const " << MI->getOperand(1).getImm(); @@ -263,7 +292,7 @@ default: llvm_unreachable("unexpected machine operand type"); case MachineOperand::MO_Register: - OS << regToString(MO.getReg()); + OS << "(get_local " << regToString(MO) << ')'; break; case MachineOperand::MO_Immediate: OS << MO.getImm(); @@ -288,9 +317,8 @@ if (NumDefs != 0) { SmallString<128> Str; raw_svector_ostream OS(Str); - OS << "\t" "set_local " - << regToString(MI->getOperand(0).getReg()) << ", " - "pop"; + const MachineOperand &Operand = MI->getOperand(0); + OS << "\tset_local " << regToString(Operand) << ", pop"; OutStreamer->EmitRawText(OS.str()); } } Index: test/CodeGen/WebAssembly/call.ll =================================================================== --- test/CodeGen/WebAssembly/call.ll +++ test/CodeGen/WebAssembly/call.ll @@ -15,9 +15,10 @@ ; CHECK-LABEL: call_i32_nullary: ; CHECK-NEXT: .result i32 +; CHECK-NEXT: .local i32 ; CHECK-NEXT: call $i32_nullary -; CHECK-NEXT: set_local @0, pop -; CHECK-NEXT: return @0 +; CHECK-NEXT: set_local 0, pop +; CHECK-NEXT: return (get_local 0) define i32 @call_i32_nullary() { %r = call i32 @i32_nullary() ret i32 %r @@ -25,9 +26,10 @@ ; CHECK-LABEL: call_i64_nullary: ; CHECK-NEXT: .result i64 +; CHECK-NEXT: .local i64 ; CHECK-NEXT: call $i64_nullary -; CHECK-NEXT: set_local @0, pop -; CHECK-NEXT: return @0 +; CHECK-NEXT: set_local 0, pop +; CHECK-NEXT: return (get_local 0) define i64 @call_i64_nullary() { %r = call i64 @i64_nullary() ret i64 %r @@ -35,9 +37,10 @@ ; CHECK-LABEL: call_float_nullary: ; CHECK-NEXT: .result f32 +; CHECK-NEXT: .local f32 ; CHECK-NEXT: call $float_nullary -; CHECK-NEXT: set_local @0, pop -; CHECK-NEXT: return @0 +; CHECK-NEXT: set_local 0, pop +; CHECK-NEXT: return (get_local 0) define float @call_float_nullary() { %r = call float @float_nullary() ret float %r @@ -45,9 +48,10 @@ ; CHECK-LABEL: call_double_nullary: ; CHECK-NEXT: .result f64 +; CHECK-NEXT: .local f64 ; CHECK-NEXT: call $double_nullary -; CHECK-NEXT: set_local @0, pop -; CHECK-NEXT: return @0 +; CHECK-NEXT: set_local 0, pop +; CHECK-NEXT: return (get_local 0) define double @call_double_nullary() { %r = call double @double_nullary() ret double %r @@ -64,11 +68,12 @@ ; CHECK-LABEL: call_i32_unary: ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .result i32 -; CHECK-NEXT: @0 -; CHECK-NEXT: set_local @1, pop -; CHECK-NEXT: call $i32_unary, @1 -; CHECK-NEXT: set_local @2, pop -; CHECK-NEXT: return @2 +; CHECK-NEXT: .local i32, i32 +; CHECK-NEXT: get_local 0 +; CHECK-NEXT: set_local 1, pop +; CHECK-NEXT: call $i32_unary, (get_local 1) +; CHECK-NEXT: set_local 2, pop +; CHECK-NEXT: return (get_local 2) define i32 @call_i32_unary(i32 %a) { %r = call i32 @i32_unary(i32 %a) ret i32 %r @@ -78,13 +83,14 @@ ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .result i32 -; CHECK-NEXT: @1 -; CHECK-NEXT: set_local @2, pop -; CHECK-NEXT: @0 -; CHECK-NEXT: set_local @3, pop -; CHECK-NEXT: call $i32_binary, @3, @2 -; CHECK-NEXT: set_local @4, pop -; CHECK-NEXT: return @4 +; CHECK-NEXT: .local i32, i32, i32 +; CHECK-NEXT: get_local 1 +; CHECK-NEXT: set_local 2, pop +; CHECK-NEXT: get_local 0 +; CHECK-NEXT: set_local 3, pop +; CHECK-NEXT: call $i32_binary, (get_local 3), (get_local 2) +; CHECK-NEXT: set_local 4, pop +; CHECK-NEXT: return (get_local 4) define i32 @call_i32_binary(i32 %a, i32 %b) { %r = call i32 @i32_binary(i32 %a, i32 %b) ret i32 %r @@ -92,9 +98,10 @@ ; CHECK-LABEL: call_indirect_void: ; CHECK-NEXT: .param i32 -; CHECK-NEXT: @0 -; CHECK-NEXT: set_local @1, pop -; CHECK-NEXT: call_indirect @1 +; CHECK-NEXT: .local i32 +; CHECK-NEXT: get_local 0 +; CHECK-NEXT: set_local 1, pop +; CHECK-NEXT: call_indirect (get_local 1) ; CHECK-NEXT: return define void @call_indirect_void(void ()* %callee) { call void %callee() @@ -104,11 +111,12 @@ ; CHECK-LABEL: call_indirect_i32: ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .result i32 -; CHECK-NEXT: @0 -; CHECK-NEXT: set_local @1, pop -; CHECK-NEXT: call_indirect @1 -; CHECK-NEXT: set_local @2, pop -; CHECK-NEXT: return @2 +; CHECK-NEXT: .local i32, i32 +; CHECK-NEXT: get_local 0 +; CHECK-NEXT: set_local 1, pop +; CHECK-NEXT: call_indirect (get_local 1) +; CHECK-NEXT: set_local 2, pop +; CHECK-NEXT: return (get_local 2) define i32 @call_indirect_i32(i32 ()* %callee) { %t = call i32 %callee() ret i32 %t Index: test/CodeGen/WebAssembly/cfg-stackify.ll =================================================================== --- test/CodeGen/WebAssembly/cfg-stackify.ll +++ test/CodeGen/WebAssembly/cfg-stackify.ll @@ -69,7 +69,7 @@ ; CHECK: block $BB2_2{{$}} ; CHECK: brif $BB2_2, {{.*}} ; CHECK: BB2_1: -; CHECK: brif $BB2_1, @16{{$}} +; CHECK: brif $BB2_1, (get_local 16){{$}} ; CHECK: BB2_2: ; CHECK: return{{$}} define void @test2(double* nocapture %p, i32 %n) { @@ -101,14 +101,14 @@ ; CHECK: block $BB3_5{{$}} ; CHECK: block $BB3_4{{$}} ; CHECK: block $BB3_2{{$}} -; CHECK: brif $BB3_2, @7{{$}} +; CHECK: brif $BB3_2, (get_local 7){{$}} ; CHECK: br $BB3_5{{$}} ; CHECK: BB3_2: -; CHECK: brif $BB3_4, @10{{$}} +; CHECK: brif $BB3_4, (get_local 10){{$}} ; CHECK: br $BB3_5{{$}} ; CHECK: BB3_4: ; CHECK: BB3_5: -; CHECK: return @6{{$}} +; CHECK: return (get_local 6){{$}} define i32 @doublediamond(i32 %a, i32 %b, i32* %p) { entry: %c = icmp eq i32 %a, 0 @@ -134,9 +134,9 @@ ; CHECK-LABEL: triangle: ; CHECK: block $BB4_2{{$}} -; CHECK: brif $BB4_2, @5{{$}} +; CHECK: brif $BB4_2, (get_local 5){{$}} ; CHECK: BB4_2: -; CHECK: return @4{{$}} +; CHECK: return (get_local 4){{$}} define i32 @triangle(i32* %p, i32 %a) { entry: %c = icmp eq i32 %a, 0 @@ -153,11 +153,11 @@ ; CHECK-LABEL: diamond: ; CHECK: block $BB5_3{{$}} ; CHECK: block $BB5_2{{$}} -; CHECK: brif $BB5_2, @5{{$}} +; CHECK: brif $BB5_2, (get_local 5){{$}} ; CHECK: br $BB5_3{{$}} ; CHECK: BB5_2: ; CHECK: BB5_3: -; CHECK: return @4{{$}} +; CHECK: return (get_local 4){{$}} define i32 @diamond(i32* %p, i32 %a) { entry: %c = icmp eq i32 %a, 0 @@ -176,7 +176,7 @@ ; CHECK-LABEL: single_block: ; CHECK-NOT: br -; CHECK: return @2{{$}} +; CHECK: return (get_local 2){{$}} define i32 @single_block(i32* %p) { entry: store volatile i32 0, i32* %p @@ -186,7 +186,7 @@ ; CHECK-LABEL: minimal_loop: ; CHECK-NOT: br ; CHECK: BB7_1: -; CHECK: store_i32 @1, @3{{$}} +; CHECK: store_i32 (get_local 1), (get_local 3){{$}} ; CHECK: br $BB7_1{{$}} define i32 @minimal_loop(i32* %p) { entry: @@ -201,8 +201,8 @@ ; CHECK-NOT: br ; CHECK: BB8_1: ; CHECK: loop $BB8_2{{$}} -; CHECK: brif $BB8_1, @6{{$}} -; CHECK: return @4{{$}} +; CHECK: brif $BB8_1, (get_local 6){{$}} +; CHECK: return (get_local 4){{$}} define i32 @simple_loop(i32* %p, i32 %a) { entry: %c = icmp eq i32 %a, 0 @@ -219,11 +219,11 @@ ; CHECK-LABEL: doubletriangle: ; CHECK: block $BB9_4{{$}} ; CHECK: block $BB9_3{{$}} -; CHECK: brif $BB9_4, @7{{$}} -; CHECK: brif $BB9_3, @10{{$}} +; CHECK: brif $BB9_4, (get_local 7){{$}} +; CHECK: brif $BB9_3, (get_local 10){{$}} ; CHECK: BB9_3: ; CHECK: BB9_4: -; CHECK: return @6{{$}} +; CHECK: return (get_local 6){{$}} define i32 @doubletriangle(i32 %a, i32 %b, i32* %p) { entry: %c = icmp eq i32 %a, 0 @@ -247,12 +247,12 @@ ; CHECK-LABEL: ifelse_earlyexits: ; CHECK: block $BB10_4{{$}} ; CHECK: block $BB10_2{{$}} -; CHECK: brif $BB10_2, @7{{$}} +; CHECK: brif $BB10_2, (get_local 7){{$}} ; CHECK: br $BB10_4{{$}} ; CHECK: BB10_2: -; CHECK: brif $BB10_4, @10{{$}} +; CHECK: brif $BB10_4, (get_local 10){{$}} ; CHECK: BB10_4: -; CHECK: return @6{{$}} +; CHECK: return (get_local 6){{$}} define i32 @ifelse_earlyexits(i32 %a, i32 %b, i32* %p) { entry: %c = icmp eq i32 %a, 0 Index: test/CodeGen/WebAssembly/comparisons_f32.ll =================================================================== --- test/CodeGen/WebAssembly/comparisons_f32.ll +++ test/CodeGen/WebAssembly/comparisons_f32.ll @@ -10,17 +10,18 @@ ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: eq @3, @3{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: eq @2, @2{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: and @5, @4{{$}} -; CHECK-NEXT: set_local @6, pop{{$}} -; CHECK-NEXT: return @6{{$}} +; CHECK-NEXT: .local f32, f32, i32, i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: eq (get_local 3), (get_local 3){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: eq (get_local 2), (get_local 2){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: and (get_local 5), (get_local 4){{$}} +; CHECK-NEXT: set_local 6, pop{{$}} +; CHECK-NEXT: return (get_local 6){{$}} define i32 @ord_f32(float %x, float %y) { %a = fcmp ord float %x, %y %b = zext i1 %a to i32 @@ -31,17 +32,18 @@ ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: ne @3, @3{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: ne @2, @2{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: ior @5, @4{{$}} -; CHECK-NEXT: set_local @6, pop{{$}} -; CHECK-NEXT: return @6{{$}} +; CHECK-NEXT: .local f32, f32, i32, i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: ne (get_local 3), (get_local 3){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: ne (get_local 2), (get_local 2){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: ior (get_local 5), (get_local 4){{$}} +; CHECK-NEXT: set_local 6, pop{{$}} +; CHECK-NEXT: return (get_local 6){{$}} define i32 @uno_f32(float %x, float %y) { %a = fcmp uno float %x, %y %b = zext i1 %a to i32 @@ -52,13 +54,14 @@ ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: eq @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local f32, f32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: eq (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @oeq_f32(float %x, float %y) { %a = fcmp oeq float %x, %y %b = zext i1 %a to i32 @@ -66,8 +69,8 @@ } ; CHECK-LABEL: une_f32: -; CHECK: ne @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ne (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @une_f32(float %x, float %y) { %a = fcmp une float %x, %y %b = zext i1 %a to i32 @@ -75,8 +78,8 @@ } ; CHECK-LABEL: olt_f32: -; CHECK: lt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: lt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @olt_f32(float %x, float %y) { %a = fcmp olt float %x, %y %b = zext i1 %a to i32 @@ -84,8 +87,8 @@ } ; CHECK-LABEL: ole_f32: -; CHECK: le @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: le (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ole_f32(float %x, float %y) { %a = fcmp ole float %x, %y %b = zext i1 %a to i32 @@ -93,8 +96,8 @@ } ; CHECK-LABEL: ogt_f32: -; CHECK: gt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: gt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ogt_f32(float %x, float %y) { %a = fcmp ogt float %x, %y %b = zext i1 %a to i32 @@ -102,8 +105,8 @@ } ; CHECK-LABEL: oge_f32: -; CHECK: ge @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ge (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @oge_f32(float %x, float %y) { %a = fcmp oge float %x, %y %b = zext i1 %a to i32 @@ -116,21 +119,22 @@ ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: eq @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: ne @2, @2{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: ne @3, @3{{$}} -; CHECK-NEXT: set_local @6, pop{{$}} -; CHECK-NEXT: ior @6, @5{{$}} -; CHECK-NEXT: set_local @7, pop{{$}} -; CHECK-NEXT: ior @4, @7{{$}} -; CHECK-NEXT: set_local @8, pop{{$}} -; CHECK-NEXT: return @8{{$}} +; CHECK-NEXT: .local f32, f32, i32, i32, i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: eq (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: ne (get_local 2), (get_local 2){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: ne (get_local 3), (get_local 3){{$}} +; CHECK-NEXT: set_local 6, pop{{$}} +; CHECK-NEXT: ior (get_local 6), (get_local 5){{$}} +; CHECK-NEXT: set_local 7, pop{{$}} +; CHECK-NEXT: ior (get_local 4), (get_local 7){{$}} +; CHECK-NEXT: set_local 8, pop{{$}} +; CHECK-NEXT: return (get_local 8){{$}} define i32 @ueq_f32(float %x, float %y) { %a = fcmp ueq float %x, %y %b = zext i1 %a to i32 @@ -138,8 +142,8 @@ } ; CHECK-LABEL: one_f32: -; CHECK: ne @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ne (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @one_f32(float %x, float %y) { %a = fcmp one float %x, %y %b = zext i1 %a to i32 @@ -147,8 +151,8 @@ } ; CHECK-LABEL: ult_f32: -; CHECK: lt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: lt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ult_f32(float %x, float %y) { %a = fcmp ult float %x, %y %b = zext i1 %a to i32 @@ -156,8 +160,8 @@ } ; CHECK-LABEL: ule_f32: -; CHECK: le @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: le (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ule_f32(float %x, float %y) { %a = fcmp ule float %x, %y %b = zext i1 %a to i32 @@ -165,8 +169,8 @@ } ; CHECK-LABEL: ugt_f32: -; CHECK: gt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: gt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ugt_f32(float %x, float %y) { %a = fcmp ugt float %x, %y %b = zext i1 %a to i32 @@ -174,8 +178,8 @@ } ; CHECK-LABEL: uge_f32: -; CHECK: ge @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ge (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @uge_f32(float %x, float %y) { %a = fcmp uge float %x, %y %b = zext i1 %a to i32 Index: test/CodeGen/WebAssembly/comparisons_f64.ll =================================================================== --- test/CodeGen/WebAssembly/comparisons_f64.ll +++ test/CodeGen/WebAssembly/comparisons_f64.ll @@ -10,17 +10,18 @@ ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: eq @3, @3{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: eq @2, @2{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: and @5, @4{{$}} -; CHECK-NEXT: set_local @6, pop{{$}} -; CHECK-NEXT: return @6{{$}} +; CHECK-NEXT: .local f64, f64, i32, i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: eq (get_local 3), (get_local 3){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: eq (get_local 2), (get_local 2){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: and (get_local 5), (get_local 4){{$}} +; CHECK-NEXT: set_local 6, pop{{$}} +; CHECK-NEXT: return (get_local 6){{$}} define i32 @ord_f64(double %x, double %y) { %a = fcmp ord double %x, %y %b = zext i1 %a to i32 @@ -31,17 +32,18 @@ ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: ne @3, @3{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: ne @2, @2{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: ior @5, @4{{$}} -; CHECK-NEXT: set_local @6, pop{{$}} -; CHECK-NEXT: return @6{{$}} +; CHECK-NEXT: .local f64, f64, i32, i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: ne (get_local 3), (get_local 3){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: ne (get_local 2), (get_local 2){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: ior (get_local 5), (get_local 4){{$}} +; CHECK-NEXT: set_local 6, pop{{$}} +; CHECK-NEXT: return (get_local 6){{$}} define i32 @uno_f64(double %x, double %y) { %a = fcmp uno double %x, %y %b = zext i1 %a to i32 @@ -52,13 +54,14 @@ ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: eq @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local f64, f64, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: eq (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @oeq_f64(double %x, double %y) { %a = fcmp oeq double %x, %y %b = zext i1 %a to i32 @@ -66,8 +69,8 @@ } ; CHECK-LABEL: une_f64: -; CHECK: ne @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ne (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @une_f64(double %x, double %y) { %a = fcmp une double %x, %y %b = zext i1 %a to i32 @@ -75,8 +78,8 @@ } ; CHECK-LABEL: olt_f64: -; CHECK: lt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: lt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @olt_f64(double %x, double %y) { %a = fcmp olt double %x, %y %b = zext i1 %a to i32 @@ -84,8 +87,8 @@ } ; CHECK-LABEL: ole_f64: -; CHECK: le @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: le (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ole_f64(double %x, double %y) { %a = fcmp ole double %x, %y %b = zext i1 %a to i32 @@ -93,8 +96,8 @@ } ; CHECK-LABEL: ogt_f64: -; CHECK: gt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: gt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ogt_f64(double %x, double %y) { %a = fcmp ogt double %x, %y %b = zext i1 %a to i32 @@ -102,8 +105,8 @@ } ; CHECK-LABEL: oge_f64: -; CHECK: ge @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ge (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @oge_f64(double %x, double %y) { %a = fcmp oge double %x, %y %b = zext i1 %a to i32 @@ -116,21 +119,22 @@ ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: eq @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: ne @2, @2{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: ne @3, @3{{$}} -; CHECK-NEXT: set_local @6, pop{{$}} -; CHECK-NEXT: ior @6, @5{{$}} -; CHECK-NEXT: set_local @7, pop{{$}} -; CHECK-NEXT: ior @4, @7{{$}} -; CHECK-NEXT: set_local @8, pop{{$}} -; CHECK-NEXT: return @8{{$}} +; CHECK-NEXT: .local f64, f64, i32, i32, i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: eq (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: ne (get_local 2), (get_local 2){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: ne (get_local 3), (get_local 3){{$}} +; CHECK-NEXT: set_local 6, pop{{$}} +; CHECK-NEXT: ior (get_local 6), (get_local 5){{$}} +; CHECK-NEXT: set_local 7, pop{{$}} +; CHECK-NEXT: ior (get_local 4), (get_local 7){{$}} +; CHECK-NEXT: set_local 8, pop{{$}} +; CHECK-NEXT: return (get_local 8){{$}} define i32 @ueq_f64(double %x, double %y) { %a = fcmp ueq double %x, %y %b = zext i1 %a to i32 @@ -138,8 +142,8 @@ } ; CHECK-LABEL: one_f64: -; CHECK: ne @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ne (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @one_f64(double %x, double %y) { %a = fcmp one double %x, %y %b = zext i1 %a to i32 @@ -147,8 +151,8 @@ } ; CHECK-LABEL: ult_f64: -; CHECK: lt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: lt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ult_f64(double %x, double %y) { %a = fcmp ult double %x, %y %b = zext i1 %a to i32 @@ -156,8 +160,8 @@ } ; CHECK-LABEL: ule_f64: -; CHECK: le @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: le (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ule_f64(double %x, double %y) { %a = fcmp ule double %x, %y %b = zext i1 %a to i32 @@ -165,8 +169,8 @@ } ; CHECK-LABEL: ugt_f64: -; CHECK: gt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: gt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ugt_f64(double %x, double %y) { %a = fcmp ugt double %x, %y %b = zext i1 %a to i32 @@ -174,8 +178,8 @@ } ; CHECK-LABEL: uge_f64: -; CHECK: ge @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ge (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @uge_f64(double %x, double %y) { %a = fcmp uge double %x, %y %b = zext i1 %a to i32 Index: test/CodeGen/WebAssembly/comparisons_i32.ll =================================================================== --- test/CodeGen/WebAssembly/comparisons_i32.ll +++ test/CodeGen/WebAssembly/comparisons_i32.ll @@ -9,13 +9,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: eq @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: eq (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @eq_i32(i32 %x, i32 %y) { %a = icmp eq i32 %x, %y %b = zext i1 %a to i32 @@ -23,8 +24,8 @@ } ; CHECK-LABEL: ne_i32: -; CHECK: ne @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ne (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ne_i32(i32 %x, i32 %y) { %a = icmp ne i32 %x, %y %b = zext i1 %a to i32 @@ -32,8 +33,8 @@ } ; CHECK-LABEL: slt_i32: -; CHECK: slt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: slt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @slt_i32(i32 %x, i32 %y) { %a = icmp slt i32 %x, %y %b = zext i1 %a to i32 @@ -41,8 +42,8 @@ } ; CHECK-LABEL: sle_i32: -; CHECK: sle @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: sle (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @sle_i32(i32 %x, i32 %y) { %a = icmp sle i32 %x, %y %b = zext i1 %a to i32 @@ -50,8 +51,8 @@ } ; CHECK-LABEL: ult_i32: -; CHECK: ult @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ult (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ult_i32(i32 %x, i32 %y) { %a = icmp ult i32 %x, %y %b = zext i1 %a to i32 @@ -59,8 +60,8 @@ } ; CHECK-LABEL: ule_i32: -; CHECK: ule @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ule (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ule_i32(i32 %x, i32 %y) { %a = icmp ule i32 %x, %y %b = zext i1 %a to i32 @@ -68,8 +69,8 @@ } ; CHECK-LABEL: sgt_i32: -; CHECK: sgt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: sgt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @sgt_i32(i32 %x, i32 %y) { %a = icmp sgt i32 %x, %y %b = zext i1 %a to i32 @@ -77,8 +78,8 @@ } ; CHECK-LABEL: sge_i32: -; CHECK: sge @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: sge (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @sge_i32(i32 %x, i32 %y) { %a = icmp sge i32 %x, %y %b = zext i1 %a to i32 @@ -86,8 +87,8 @@ } ; CHECK-LABEL: ugt_i32: -; CHECK: ugt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ugt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ugt_i32(i32 %x, i32 %y) { %a = icmp ugt i32 %x, %y %b = zext i1 %a to i32 @@ -95,8 +96,8 @@ } ; CHECK-LABEL: uge_i32: -; CHECK: uge @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: uge (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @uge_i32(i32 %x, i32 %y) { %a = icmp uge i32 %x, %y %b = zext i1 %a to i32 Index: test/CodeGen/WebAssembly/comparisons_i64.ll =================================================================== --- test/CodeGen/WebAssembly/comparisons_i64.ll +++ test/CodeGen/WebAssembly/comparisons_i64.ll @@ -9,13 +9,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: eq @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: eq (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @eq_i64(i64 %x, i64 %y) { %a = icmp eq i64 %x, %y %b = zext i1 %a to i32 @@ -23,8 +24,8 @@ } ; CHECK-LABEL: ne_i64: -; CHECK: ne @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ne (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ne_i64(i64 %x, i64 %y) { %a = icmp ne i64 %x, %y %b = zext i1 %a to i32 @@ -32,8 +33,8 @@ } ; CHECK-LABEL: slt_i64: -; CHECK: slt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: slt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @slt_i64(i64 %x, i64 %y) { %a = icmp slt i64 %x, %y %b = zext i1 %a to i32 @@ -41,8 +42,8 @@ } ; CHECK-LABEL: sle_i64: -; CHECK: sle @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: sle (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @sle_i64(i64 %x, i64 %y) { %a = icmp sle i64 %x, %y %b = zext i1 %a to i32 @@ -50,8 +51,8 @@ } ; CHECK-LABEL: ult_i64: -; CHECK: ult @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ult (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ult_i64(i64 %x, i64 %y) { %a = icmp ult i64 %x, %y %b = zext i1 %a to i32 @@ -59,8 +60,8 @@ } ; CHECK-LABEL: ule_i64: -; CHECK: ule @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ule (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ule_i64(i64 %x, i64 %y) { %a = icmp ule i64 %x, %y %b = zext i1 %a to i32 @@ -68,8 +69,8 @@ } ; CHECK-LABEL: sgt_i64: -; CHECK: sgt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: sgt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @sgt_i64(i64 %x, i64 %y) { %a = icmp sgt i64 %x, %y %b = zext i1 %a to i32 @@ -77,8 +78,8 @@ } ; CHECK-LABEL: sge_i64: -; CHECK: sge @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: sge (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @sge_i64(i64 %x, i64 %y) { %a = icmp sge i64 %x, %y %b = zext i1 %a to i32 @@ -86,8 +87,8 @@ } ; CHECK-LABEL: ugt_i64: -; CHECK: ugt @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: ugt (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @ugt_i64(i64 %x, i64 %y) { %a = icmp ugt i64 %x, %y %b = zext i1 %a to i32 @@ -95,8 +96,8 @@ } ; CHECK-LABEL: uge_i64: -; CHECK: uge @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: uge (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define i32 @uge_i64(i64 %x, i64 %y) { %a = icmp uge i64 %x, %y %b = zext i1 %a to i32 Index: test/CodeGen/WebAssembly/conv.ll =================================================================== --- test/CodeGen/WebAssembly/conv.ll +++ test/CodeGen/WebAssembly/conv.ll @@ -8,11 +8,12 @@ ; CHECK-LABEL: i32_wrap_i64: ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i32_wrap @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i32_wrap (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @i32_wrap_i64(i64 %x) { %a = trunc i64 %x to i32 ret i32 %a @@ -21,11 +22,12 @@ ; CHECK-LABEL: i64_extend_s_i32: ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .result i64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i64_extend_s @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i64_extend_s (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @i64_extend_s_i32(i32 %x) { %a = sext i32 %x to i64 ret i64 %a @@ -34,11 +36,12 @@ ; CHECK-LABEL: i64_extend_u_i32: ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .result i64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i64_extend_u @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i64_extend_u (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @i64_extend_u_i32(i32 %x) { %a = zext i32 %x to i64 ret i64 %a @@ -47,11 +50,12 @@ ; CHECK-LABEL: i32_trunc_s_f32: ; CHECK-NEXT: .param f32 ; CHECK-NEXT: .result i32 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i32_trunc_s @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i32_trunc_s (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @i32_trunc_s_f32(float %x) { %a = fptosi float %x to i32 ret i32 %a @@ -60,11 +64,12 @@ ; CHECK-LABEL: i32_trunc_u_f32: ; CHECK-NEXT: .param f32 ; CHECK-NEXT: .result i32 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i32_trunc_u @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i32_trunc_u (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @i32_trunc_u_f32(float %x) { %a = fptoui float %x to i32 ret i32 %a @@ -73,11 +78,12 @@ ; CHECK-LABEL: i32_trunc_s_f64: ; CHECK-NEXT: .param f64 ; CHECK-NEXT: .result i32 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i32_trunc_s @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f64, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i32_trunc_s (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @i32_trunc_s_f64(double %x) { %a = fptosi double %x to i32 ret i32 %a @@ -86,11 +92,12 @@ ; CHECK-LABEL: i32_trunc_u_f64: ; CHECK-NEXT: .param f64 ; CHECK-NEXT: .result i32 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i32_trunc_u @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f64, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i32_trunc_u (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @i32_trunc_u_f64(double %x) { %a = fptoui double %x to i32 ret i32 %a @@ -99,11 +106,12 @@ ; CHECK-LABEL: i64_trunc_s_f32: ; CHECK-NEXT: .param f32 ; CHECK-NEXT: .result i64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i64_trunc_s @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f32, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i64_trunc_s (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @i64_trunc_s_f32(float %x) { %a = fptosi float %x to i64 ret i64 %a @@ -112,11 +120,12 @@ ; CHECK-LABEL: i64_trunc_u_f32: ; CHECK-NEXT: .param f32 ; CHECK-NEXT: .result i64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i64_trunc_u @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f32, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i64_trunc_u (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @i64_trunc_u_f32(float %x) { %a = fptoui float %x to i64 ret i64 %a @@ -125,11 +134,12 @@ ; CHECK-LABEL: i64_trunc_s_f64: ; CHECK-NEXT: .param f64 ; CHECK-NEXT: .result i64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i64_trunc_s @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f64, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i64_trunc_s (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @i64_trunc_s_f64(double %x) { %a = fptosi double %x to i64 ret i64 %a @@ -138,11 +148,12 @@ ; CHECK-LABEL: i64_trunc_u_f64: ; CHECK-NEXT: .param f64 ; CHECK-NEXT: .result i64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: i64_trunc_u @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f64, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: i64_trunc_u (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @i64_trunc_u_f64(double %x) { %a = fptoui double %x to i64 ret i64 %a @@ -151,11 +162,12 @@ ; CHECK-LABEL: f32_convert_s_i32: ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .result f32 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f32_convert_s @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, f32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f32_convert_s (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define float @f32_convert_s_i32(i32 %x) { %a = sitofp i32 %x to float ret float %a @@ -164,11 +176,12 @@ ; CHECK-LABEL: f32_convert_u_i32: ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .result f32 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f32_convert_u @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, f32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f32_convert_u (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define float @f32_convert_u_i32(i32 %x) { %a = uitofp i32 %x to float ret float %a @@ -177,11 +190,12 @@ ; CHECK-LABEL: f64_convert_s_i32: ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .result f64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f64_convert_s @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, f64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f64_convert_s (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define double @f64_convert_s_i32(i32 %x) { %a = sitofp i32 %x to double ret double %a @@ -190,11 +204,12 @@ ; CHECK-LABEL: f64_convert_u_i32: ; CHECK-NEXT: .param i32 ; CHECK-NEXT: .result f64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f64_convert_u @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, f64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f64_convert_u (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define double @f64_convert_u_i32(i32 %x) { %a = uitofp i32 %x to double ret double %a @@ -203,11 +218,12 @@ ; CHECK-LABEL: f32_convert_s_i64: ; CHECK-NEXT: .param i64 ; CHECK-NEXT: .result f32 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f32_convert_s @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, f32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f32_convert_s (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define float @f32_convert_s_i64(i64 %x) { %a = sitofp i64 %x to float ret float %a @@ -216,11 +232,12 @@ ; CHECK-LABEL: f32_convert_u_i64: ; CHECK-NEXT: .param i64 ; CHECK-NEXT: .result f32 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f32_convert_u @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, f32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f32_convert_u (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define float @f32_convert_u_i64(i64 %x) { %a = uitofp i64 %x to float ret float %a @@ -229,11 +246,12 @@ ; CHECK-LABEL: f64_convert_s_i64: ; CHECK-NEXT: .param i64 ; CHECK-NEXT: .result f64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f64_convert_s @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, f64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f64_convert_s (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define double @f64_convert_s_i64(i64 %x) { %a = sitofp i64 %x to double ret double %a @@ -242,11 +260,12 @@ ; CHECK-LABEL: f64_convert_u_i64: ; CHECK-NEXT: .param i64 ; CHECK-NEXT: .result f64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f64_convert_u @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, f64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f64_convert_u (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define double @f64_convert_u_i64(i64 %x) { %a = uitofp i64 %x to double ret double %a @@ -255,11 +274,12 @@ ; CHECK-LABEL: f64_promote_f32: ; CHECK-NEXT: .param f32 ; CHECK-NEXT: .result f64 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f64_promote @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f32, f64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f64_promote (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define double @f64_promote_f32(float %x) { %a = fpext float %x to double ret double %a @@ -268,11 +288,12 @@ ; CHECK-LABEL: f32_demote_f64: ; CHECK-NEXT: .param f64 ; CHECK-NEXT: .result f32 -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: f32_demote @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local f64, f32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: f32_demote (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define float @f32_demote_f64(double %x) { %a = fptrunc double %x to float ret float %a Index: test/CodeGen/WebAssembly/f32.ll =================================================================== --- test/CodeGen/WebAssembly/f32.ll +++ test/CodeGen/WebAssembly/f32.ll @@ -18,109 +18,110 @@ ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .result f32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: add @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local f32, f32, f32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: add (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define float @fadd32(float %x, float %y) { %a = fadd float %x, %y ret float %a } ; CHECK-LABEL: fsub32: -; CHECK: sub @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: sub (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define float @fsub32(float %x, float %y) { %a = fsub float %x, %y ret float %a } ; CHECK-LABEL: fmul32: -; CHECK: mul @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: mul (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define float @fmul32(float %x, float %y) { %a = fmul float %x, %y ret float %a } ; CHECK-LABEL: fdiv32: -; CHECK: div @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: div (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define float @fdiv32(float %x, float %y) { %a = fdiv float %x, %y ret float %a } ; CHECK-LABEL: fabs32: -; CHECK: abs @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: abs (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define float @fabs32(float %x) { %a = call float @llvm.fabs.f32(float %x) ret float %a } ; CHECK-LABEL: fneg32: -; CHECK: neg @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: neg (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define float @fneg32(float %x) { %a = fsub float -0., %x ret float %a } ; CHECK-LABEL: copysign32: -; CHECK: copysign @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: copysign (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define float @copysign32(float %x, float %y) { %a = call float @llvm.copysign.f32(float %x, float %y) ret float %a } ; CHECK-LABEL: sqrt32: -; CHECK: sqrt @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: sqrt (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define float @sqrt32(float %x) { %a = call float @llvm.sqrt.f32(float %x) ret float %a } ; CHECK-LABEL: ceil32: -; CHECK: ceil @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: ceil (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define float @ceil32(float %x) { %a = call float @llvm.ceil.f32(float %x) ret float %a } ; CHECK-LABEL: floor32: -; CHECK: floor @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: floor (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define float @floor32(float %x) { %a = call float @llvm.floor.f32(float %x) ret float %a } ; CHECK-LABEL: trunc32: -; CHECK: trunc @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: trunc (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define float @trunc32(float %x) { %a = call float @llvm.trunc.f32(float %x) ret float %a } ; CHECK-LABEL: nearest32: -; CHECK: nearest @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: nearest (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define float @nearest32(float %x) { %a = call float @llvm.nearbyint.f32(float %x) ret float %a } ; CHECK-LABEL: nearest32_via_rint: -; CHECK: nearest @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: nearest (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define float @nearest32_via_rint(float %x) { %a = call float @llvm.rint.f32(float %x) ret float %a Index: test/CodeGen/WebAssembly/f64.ll =================================================================== --- test/CodeGen/WebAssembly/f64.ll +++ test/CodeGen/WebAssembly/f64.ll @@ -18,109 +18,110 @@ ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .param f64{{$}} ; CHECK-NEXT: .result f64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: add @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local f64, f64, f64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: add (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define double @fadd64(double %x, double %y) { %a = fadd double %x, %y ret double %a } ; CHECK-LABEL: fsub64: -; CHECK: sub @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: sub (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define double @fsub64(double %x, double %y) { %a = fsub double %x, %y ret double %a } ; CHECK-LABEL: fmul64: -; CHECK: mul @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: mul (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define double @fmul64(double %x, double %y) { %a = fmul double %x, %y ret double %a } ; CHECK-LABEL: fdiv64: -; CHECK: div @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: div (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define double @fdiv64(double %x, double %y) { %a = fdiv double %x, %y ret double %a } ; CHECK-LABEL: fabs64: -; CHECK: abs @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: abs (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define double @fabs64(double %x) { %a = call double @llvm.fabs.f64(double %x) ret double %a } ; CHECK-LABEL: fneg64: -; CHECK: neg @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: neg (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define double @fneg64(double %x) { %a = fsub double -0., %x ret double %a } ; CHECK-LABEL: copysign64: -; CHECK: copysign @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} +; CHECK: copysign (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} define double @copysign64(double %x, double %y) { %a = call double @llvm.copysign.f64(double %x, double %y) ret double %a } ; CHECK-LABEL: sqrt64: -; CHECK: sqrt @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: sqrt (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define double @sqrt64(double %x) { %a = call double @llvm.sqrt.f64(double %x) ret double %a } ; CHECK-LABEL: ceil64: -; CHECK: ceil @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: ceil (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define double @ceil64(double %x) { %a = call double @llvm.ceil.f64(double %x) ret double %a } ; CHECK-LABEL: floor64: -; CHECK: floor @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: floor (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define double @floor64(double %x) { %a = call double @llvm.floor.f64(double %x) ret double %a } ; CHECK-LABEL: trunc64: -; CHECK: trunc @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: trunc (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define double @trunc64(double %x) { %a = call double @llvm.trunc.f64(double %x) ret double %a } ; CHECK-LABEL: nearest64: -; CHECK: nearest @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: nearest (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define double @nearest64(double %x) { %a = call double @llvm.nearbyint.f64(double %x) ret double %a } ; CHECK-LABEL: nearest64_via_rint: -; CHECK: nearest @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: nearest (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define double @nearest64_via_rint(double %x) { %a = call double @llvm.rint.f64(double %x) ret double %a Index: test/CodeGen/WebAssembly/func.ll =================================================================== --- test/CodeGen/WebAssembly/func.ll +++ test/CodeGen/WebAssembly/func.ll @@ -14,9 +14,10 @@ ; CHECK-LABEL: f1: ; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: .local i32{{$}} ; CHECK-NEXT: i32.const 0{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: i32.return (get_local 0){{$}} ; CHECK: .size f1, define i32 @f1() { ret i32 0 @@ -26,9 +27,10 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param f32{{$}} ; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: .local i32{{$}} ; CHECK-NEXT: i32.const 0{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: i32.return (get_local 2){{$}} ; CHECK: .size f2, define i32 @f2(i32 %p1, float %p2) { ret i32 0 @@ -37,7 +39,8 @@ ; CHECK-LABEL: f3: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param f32{{$}} -; CHECK-NEXT: return{{$}} +; CHECK-NOT: .local +; CHECK-NEXT: void.return{{$}} ; CHECK: .size f3, define void @f3(i32 %p1, float %p2) { ret void Index: test/CodeGen/WebAssembly/i32.ll =================================================================== --- test/CodeGen/WebAssembly/i32.ll +++ test/CodeGen/WebAssembly/i32.ll @@ -13,13 +13,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: add @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: add (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @add32(i32 %x, i32 %y) { %a = add i32 %x, %y ret i32 %a @@ -29,13 +30,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: sub @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: sub (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @sub32(i32 %x, i32 %y) { %a = sub i32 %x, %y ret i32 %a @@ -45,13 +47,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: mul @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: mul (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @mul32(i32 %x, i32 %y) { %a = mul i32 %x, %y ret i32 %a @@ -61,13 +64,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: sdiv @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: sdiv (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @sdiv32(i32 %x, i32 %y) { %a = sdiv i32 %x, %y ret i32 %a @@ -77,13 +81,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: udiv @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: udiv (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @udiv32(i32 %x, i32 %y) { %a = udiv i32 %x, %y ret i32 %a @@ -93,13 +98,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: srem @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: srem (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @srem32(i32 %x, i32 %y) { %a = srem i32 %x, %y ret i32 %a @@ -109,13 +115,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: urem @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: urem (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @urem32(i32 %x, i32 %y) { %a = urem i32 %x, %y ret i32 %a @@ -125,13 +132,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: and @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: and (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @and32(i32 %x, i32 %y) { %a = and i32 %x, %y ret i32 %a @@ -141,13 +149,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: ior @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: ior (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @ior32(i32 %x, i32 %y) { %a = or i32 %x, %y ret i32 %a @@ -157,13 +166,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: xor @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: xor (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @xor32(i32 %x, i32 %y) { %a = xor i32 %x, %y ret i32 %a @@ -173,13 +183,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: shl @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: shl (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @shl32(i32 %x, i32 %y) { %a = shl i32 %x, %y ret i32 %a @@ -189,13 +200,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: shr_u @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: shr_u (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @shr32(i32 %x, i32 %y) { %a = lshr i32 %x, %y ret i32 %a @@ -205,13 +217,14 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: shr_s @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i32, i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: shr_s (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i32 @sar32(i32 %x, i32 %y) { %a = ashr i32 %x, %y ret i32 %a @@ -220,11 +233,12 @@ ; CHECK-LABEL: clz32: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: clz @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: clz (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @clz32(i32 %x) { %a = call i32 @llvm.ctlz.i32(i32 %x, i1 false) ret i32 %a @@ -233,11 +247,12 @@ ; CHECK-LABEL: clz32_zero_undef: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: clz @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: clz (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @clz32_zero_undef(i32 %x) { %a = call i32 @llvm.ctlz.i32(i32 %x, i1 true) ret i32 %a @@ -246,11 +261,12 @@ ; CHECK-LABEL: ctz32: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: ctz @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: ctz (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @ctz32(i32 %x) { %a = call i32 @llvm.cttz.i32(i32 %x, i1 false) ret i32 %a @@ -259,11 +275,12 @@ ; CHECK-LABEL: ctz32_zero_undef: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: ctz @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: ctz (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @ctz32_zero_undef(i32 %x) { %a = call i32 @llvm.cttz.i32(i32 %x, i1 true) ret i32 %a @@ -272,11 +289,12 @@ ; CHECK-LABEL: popcnt32: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: popcnt @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: popcnt (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @popcnt32(i32 %x) { %a = call i32 @llvm.ctpop.i32(i32 %x) ret i32 %a Index: test/CodeGen/WebAssembly/i64.ll =================================================================== --- test/CodeGen/WebAssembly/i64.ll +++ test/CodeGen/WebAssembly/i64.ll @@ -13,13 +13,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: add @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: add (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @add64(i64 %x, i64 %y) { %a = add i64 %x, %y ret i64 %a @@ -29,13 +30,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: sub @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: sub (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @sub64(i64 %x, i64 %y) { %a = sub i64 %x, %y ret i64 %a @@ -45,13 +47,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: mul @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: mul (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @mul64(i64 %x, i64 %y) { %a = mul i64 %x, %y ret i64 %a @@ -61,13 +64,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: sdiv @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: sdiv (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @sdiv64(i64 %x, i64 %y) { %a = sdiv i64 %x, %y ret i64 %a @@ -77,13 +81,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: udiv @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: udiv (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @udiv64(i64 %x, i64 %y) { %a = udiv i64 %x, %y ret i64 %a @@ -93,13 +98,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: srem @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: srem (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @srem64(i64 %x, i64 %y) { %a = srem i64 %x, %y ret i64 %a @@ -109,13 +115,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: urem @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: urem (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @urem64(i64 %x, i64 %y) { %a = urem i64 %x, %y ret i64 %a @@ -125,13 +132,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: and @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: and (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @and64(i64 %x, i64 %y) { %a = and i64 %x, %y ret i64 %a @@ -141,13 +149,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: ior @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: ior (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @ior64(i64 %x, i64 %y) { %a = or i64 %x, %y ret i64 %a @@ -157,13 +166,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: xor @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: xor (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @xor64(i64 %x, i64 %y) { %a = xor i64 %x, %y ret i64 %a @@ -173,13 +183,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: shl @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: shl (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @shl64(i64 %x, i64 %y) { %a = shl i64 %x, %y ret i64 %a @@ -189,13 +200,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: shr_u @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: shr_u (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @shr64(i64 %x, i64 %y) { %a = lshr i64 %x, %y ret i64 %a @@ -205,13 +217,14 @@ ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: shr_s @3, @2{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: return @4{{$}} +; CHECK-NEXT: .local i64, i64, i64{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: shr_s (get_local 3), (get_local 2){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: return (get_local 4){{$}} define i64 @sar64(i64 %x, i64 %y) { %a = ashr i64 %x, %y ret i64 %a @@ -220,11 +233,12 @@ ; CHECK-LABEL: clz64: ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: clz @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: clz (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @clz64(i64 %x) { %a = call i64 @llvm.ctlz.i64(i64 %x, i1 false) ret i64 %a @@ -233,11 +247,12 @@ ; CHECK-LABEL: clz64_zero_undef: ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: clz @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: clz (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @clz64_zero_undef(i64 %x) { %a = call i64 @llvm.ctlz.i64(i64 %x, i1 true) ret i64 %a @@ -246,11 +261,12 @@ ; CHECK-LABEL: ctz64: ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: ctz @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: ctz (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @ctz64(i64 %x) { %a = call i64 @llvm.cttz.i64(i64 %x, i1 false) ret i64 %a @@ -259,11 +275,12 @@ ; CHECK-LABEL: ctz64_zero_undef: ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: ctz @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: ctz (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @ctz64_zero_undef(i64 %x) { %a = call i64 @llvm.cttz.i64(i64 %x, i1 true) ret i64 %a @@ -272,11 +289,12 @@ ; CHECK-LABEL: popcnt64: ; CHECK-NEXT: .param i64{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: popcnt @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i64, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: popcnt (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @popcnt64(i64 %x) { %a = call i64 @llvm.ctpop.i64(i64 %x) ret i64 %a Index: test/CodeGen/WebAssembly/immediates.ll =================================================================== --- test/CodeGen/WebAssembly/immediates.ll +++ test/CodeGen/WebAssembly/immediates.ll @@ -7,216 +7,240 @@ ; CHECK-LABEL: zero_i32: ; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: i32.const 0{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i32 @zero_i32() { ret i32 0 } ; CHECK-LABEL: one_i32: ; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: i32.const 1{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i32 @one_i32() { ret i32 1 } ; CHECK-LABEL: max_i32: ; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: i32.const 2147483647{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i32 @max_i32() { ret i32 2147483647 } ; CHECK-LABEL: min_i32: ; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: i32.const -2147483648{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i32 @min_i32() { ret i32 -2147483648 } ; CHECK-LABEL: zero_i64: ; CHECK-NEXT: .result i64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: i64.const 0{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i64 @zero_i64() { ret i64 0 } ; CHECK-LABEL: one_i64: ; CHECK-NEXT: .result i64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: i64.const 1{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i64 @one_i64() { ret i64 1 } ; CHECK-LABEL: max_i64: ; CHECK-NEXT: .result i64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: i64.const 9223372036854775807{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i64 @max_i64() { ret i64 9223372036854775807 } ; CHECK-LABEL: min_i64: ; CHECK-NEXT: .result i64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: i64.const -9223372036854775808{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i64 @min_i64() { ret i64 -9223372036854775808 } ; CHECK-LABEL: negzero_f32: ; CHECK-NEXT: .result f32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f32.const -0x0p0{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define float @negzero_f32() { ret float -0.0 } ; CHECK-LABEL: zero_f32: ; CHECK-NEXT: .result f32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f32.const 0x0p0{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define float @zero_f32() { ret float 0.0 } ; CHECK-LABEL: one_f32: ; CHECK-NEXT: .result f32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f32.const 0x1p0{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define float @one_f32() { ret float 1.0 } ; CHECK-LABEL: two_f32: ; CHECK-NEXT: .result f32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f32.const 0x1p1{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define float @two_f32() { ret float 2.0 } ; CHECK-LABEL: nan_f32: ; CHECK-NEXT: .result f32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f32.const nan -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define float @nan_f32() { ret float 0x7FF8000000000000 } ; CHECK-LABEL: negnan_f32: ; CHECK-NEXT: .result f32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f32.const -nan -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define float @negnan_f32() { ret float 0xFFF8000000000000 } ; CHECK-LABEL: inf_f32: ; CHECK-NEXT: .result f32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f32.const infinity -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define float @inf_f32() { ret float 0x7FF0000000000000 } ; CHECK-LABEL: neginf_f32: ; CHECK-NEXT: .result f32{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f32.const -infinity -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define float @neginf_f32() { ret float 0xFFF0000000000000 } ; CHECK-LABEL: negzero_f64: ; CHECK-NEXT: .result f64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f64.const -0x0p0{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define double @negzero_f64() { ret double -0.0 } ; CHECK-LABEL: zero_f64: ; CHECK-NEXT: .result f64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f64.const 0x0p0{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define double @zero_f64() { ret double 0.0 } ; CHECK-LABEL: one_f64: ; CHECK-NEXT: .result f64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f64.const 0x1p0{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define double @one_f64() { ret double 1.0 } ; CHECK-LABEL: two_f64: ; CHECK-NEXT: .result f64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f64.const 0x1p1{{$}} -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define double @two_f64() { ret double 2.0 } ; CHECK-LABEL: nan_f64: ; CHECK-NEXT: .result f64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f64.const nan -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define double @nan_f64() { ret double 0x7FF8000000000000 } ; CHECK-LABEL: negnan_f64: ; CHECK-NEXT: .result f64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f64.const -nan -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define double @negnan_f64() { ret double 0xFFF8000000000000 } ; CHECK-LABEL: inf_f64: ; CHECK-NEXT: .result f64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f64.const infinity -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define double @inf_f64() { ret double 0x7FF0000000000000 } ; CHECK-LABEL: neginf_f64: ; CHECK-NEXT: .result f64{{$}} +; CHECK-NEXT: .local ; CHECK-NEXT: f64.const -infinity -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define double @neginf_f64() { ret double 0xFFF0000000000000 } Index: test/CodeGen/WebAssembly/load-ext.ll =================================================================== --- test/CodeGen/WebAssembly/load-ext.ll +++ test/CodeGen/WebAssembly/load-ext.ll @@ -6,8 +6,8 @@ target triple = "wasm32-unknown-unknown" ; CHECK-LABEL: sext_i8_i32: -; CHECK: load_s_i8_i32 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_s_i8_i32 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define i32 @sext_i8_i32(i8 *%p) { %v = load i8, i8* %p %e = sext i8 %v to i32 @@ -15,8 +15,8 @@ } ; CHECK-LABEL: zext_i8_i32: -; CHECK: load_u_i8_i32 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_u_i8_i32 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define i32 @zext_i8_i32(i8 *%p) { %v = load i8, i8* %p %e = zext i8 %v to i32 @@ -24,8 +24,8 @@ } ; CHECK-LABEL: sext_i16_i32: -; CHECK: load_s_i16_i32 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_s_i16_i32 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define i32 @sext_i16_i32(i16 *%p) { %v = load i16, i16* %p %e = sext i16 %v to i32 @@ -33,8 +33,8 @@ } ; CHECK-LABEL: zext_i16_i32: -; CHECK: load_u_i16_i32 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_u_i16_i32 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define i32 @zext_i16_i32(i16 *%p) { %v = load i16, i16* %p %e = zext i16 %v to i32 @@ -42,8 +42,8 @@ } ; CHECK-LABEL: sext_i8_i64: -; CHECK: load_s_i8_i64 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_s_i8_i64 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define i64 @sext_i8_i64(i8 *%p) { %v = load i8, i8* %p %e = sext i8 %v to i64 @@ -51,8 +51,8 @@ } ; CHECK-LABEL: zext_i8_i64: -; CHECK: load_u_i8_i64 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_u_i8_i64 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define i64 @zext_i8_i64(i8 *%p) { %v = load i8, i8* %p %e = zext i8 %v to i64 @@ -60,8 +60,8 @@ } ; CHECK-LABEL: sext_i16_i64: -; CHECK: load_s_i16_i64 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_s_i16_i64 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define i64 @sext_i16_i64(i16 *%p) { %v = load i16, i16* %p %e = sext i16 %v to i64 @@ -69,8 +69,8 @@ } ; CHECK-LABEL: zext_i16_i64: -; CHECK: load_u_i16_i64 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_u_i16_i64 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define i64 @zext_i16_i64(i16 *%p) { %v = load i16, i16* %p %e = zext i16 %v to i64 @@ -78,8 +78,8 @@ } ; CHECK-LABEL: sext_i32_i64: -; CHECK: load_s_i32_i64 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_s_i32_i64 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} define i64 @sext_i32_i64(i32 *%p) { %v = load i32, i32* %p %e = sext i32 %v to i64 @@ -87,8 +87,8 @@ } ; CHECK-LABEL: zext_i32_i64: -; CHECK: load_u_i32_i64 @1{{$}} -; CHECK: set_local @2, pop{{$}} +; CHECK: load_u_i32_i64 (get_local 1){{$}} +; CHECK: set_local 2, pop{{$}} define i64 @zext_i32_i64(i32 *%p) { %v = load i32, i32* %p %e = zext i32 %v to i64 Index: test/CodeGen/WebAssembly/load-store-i1.ll =================================================================== --- test/CodeGen/WebAssembly/load-store-i1.ll +++ test/CodeGen/WebAssembly/load-store-i1.ll @@ -6,9 +6,9 @@ target triple = "wasm32-unknown-unknown" ; CHECK-LABEL: load_u_i1_i32: -; CHECK: load_u_i8_i32 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK: load_u_i8_i32 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @load_u_i1_i32(i1* %p) { %v = load i1, i1* %p %e = zext i1 %v to i32 @@ -16,15 +16,15 @@ } ; CHECK-LABEL: load_s_i1_i32: -; CHECK: load_u_i8_i32 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_u_i8_i32 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} ; CHECK-NEXT: i32.const 31{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: shl @2, @3{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: shr_s @4, @3{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: return @5{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: shl (get_local 2), (get_local 3){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: shr_s (get_local 4), (get_local 3){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: return (get_local 5){{$}} define i32 @load_s_i1_i32(i1* %p) { %v = load i1, i1* %p %e = sext i1 %v to i32 @@ -32,9 +32,9 @@ } ; CHECK-LABEL: load_u_i1_i64: -; CHECK: load_u_i8_i64 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK: load_u_i8_i64 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @load_u_i1_i64(i1* %p) { %v = load i1, i1* %p %e = zext i1 %v to i64 @@ -42,15 +42,15 @@ } ; CHECK-LABEL: load_s_i1_i64: -; CHECK: load_u_i8_i64 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} +; CHECK: load_u_i8_i64 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} ; CHECK-NEXT: i64.const 63{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: shl @2, @3{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: shr_s @4, @3{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: return @5{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: shl (get_local 2), (get_local 3){{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: shr_s (get_local 4), (get_local 3){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: return (get_local 5){{$}} define i64 @load_s_i1_i64(i1* %p) { %v = load i1, i1* %p %e = sext i1 %v to i64 @@ -59,10 +59,10 @@ ; CHECK-LABEL: store_i32_i1: ; CHECK: i32.const 1{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: and @3, @4{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: store_i8 @2, @5{{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: and (get_local 3), (get_local 4){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: store_i8 (get_local 2), (get_local 5){{$}} define void @store_i32_i1(i1* %p, i32 %v) { %t = trunc i32 %v to i1 store i1 %t, i1* %p @@ -71,10 +71,10 @@ ; CHECK-LABEL: store_i64_i1: ; CHECK: i64.const 1{{$}} -; CHECK-NEXT: set_local @4, pop{{$}} -; CHECK-NEXT: and @3, @4{{$}} -; CHECK-NEXT: set_local @5, pop{{$}} -; CHECK-NEXT: store_i8 @2, @5{{$}} +; CHECK-NEXT: set_local 4, pop{{$}} +; CHECK-NEXT: and (get_local 3), (get_local 4){{$}} +; CHECK-NEXT: set_local 5, pop{{$}} +; CHECK-NEXT: store_i8 (get_local 2), (get_local 5){{$}} define void @store_i64_i1(i1* %p, i64 %v) { %t = trunc i64 %v to i1 store i1 %t, i1* %p Index: test/CodeGen/WebAssembly/load.ll =================================================================== --- test/CodeGen/WebAssembly/load.ll +++ test/CodeGen/WebAssembly/load.ll @@ -8,11 +8,12 @@ ; CHECK-LABEL: ldi32: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: load_i32 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: load_i32 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @ldi32(i32 *%p) { %v = load i32, i32* %p ret i32 %v @@ -21,11 +22,12 @@ ; CHECK-LABEL: ldi64: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i64{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: load_i64 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, i64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: load_i64 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i64 @ldi64(i64 *%p) { %v = load i64, i64* %p ret i64 %v @@ -34,11 +36,12 @@ ; CHECK-LABEL: ldf32: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result f32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: load_f32 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, f32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: load_f32 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define float @ldf32(float *%p) { %v = load float, float* %p ret float %v @@ -47,11 +50,12 @@ ; CHECK-LABEL: ldf64: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result f64{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @1, pop{{$}} -; CHECK-NEXT: load_f64 @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32, f64{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 1, pop{{$}} +; CHECK-NEXT: load_f64 (get_local 1){{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define double @ldf64(double *%p) { %v = load double, double* %p ret double %v Index: test/CodeGen/WebAssembly/memory-addr32.ll =================================================================== --- test/CodeGen/WebAssembly/memory-addr32.ll +++ test/CodeGen/WebAssembly/memory-addr32.ll @@ -11,9 +11,10 @@ ; CHECK-LABEL: page_size: ; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: .local i32{{$}} ; CHECK-NEXT: page_size -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i32 @page_size() { %a = call i32 @llvm.wasm.page.size.i32() ret i32 %a @@ -21,9 +22,10 @@ ; CHECK-LABEL: memory_size: ; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: .local i32{{$}} ; CHECK-NEXT: memory_size -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i32 @memory_size() { %a = call i32 @llvm.wasm.memory.size.i32() ret i32 %a @@ -31,7 +33,8 @@ ; CHECK-LABEL: resize_memory: ; CHECK-NEXT: .param i32 -; CHECK: resize_memory @1 +; CHECK-NEXT: .local i32{{$}} +; CHECK: resize_memory (get_local 1) ; CHECK-NEXT: return define void @resize_memory(i32 %n) { call void @llvm.wasm.resize.memory.i32(i32 %n) Index: test/CodeGen/WebAssembly/memory-addr64.ll =================================================================== --- test/CodeGen/WebAssembly/memory-addr64.ll +++ test/CodeGen/WebAssembly/memory-addr64.ll @@ -11,9 +11,10 @@ ; CHECK-LABEL: page_size: ; CHECK-NEXT: .result i64{{$}} +; CHECK-NEXT: .local i64{{$}} ; CHECK-NEXT: page_size -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i64 @page_size() { %a = call i64 @llvm.wasm.page.size.i64() ret i64 %a @@ -21,9 +22,10 @@ ; CHECK-LABEL: memory_size: ; CHECK-NEXT: .result i64{{$}} +; CHECK-NEXT: .local i64{{$}} ; CHECK-NEXT: memory_size -; CHECK-NEXT: set_local @0, pop{{$}} -; CHECK-NEXT: return @0{{$}} +; CHECK-NEXT: set_local 0, pop{{$}} +; CHECK-NEXT: return (get_local 0){{$}} define i64 @memory_size() { %a = call i64 @llvm.wasm.memory.size.i64() ret i64 %a @@ -31,7 +33,8 @@ ; CHECK-LABEL: resize_memory: ; CHECK-NEXT: .param i64 -; CHECK: resize_memory @1 +; CHECK-NEXT: .local i64{{$}} +; CHECK: resize_memory (get_local 1) ; CHECK-NEXT: return define void @resize_memory(i64 %n) { call void @llvm.wasm.resize.memory.i64(i64 %n) Index: test/CodeGen/WebAssembly/phi.ll =================================================================== --- test/CodeGen/WebAssembly/phi.ll +++ test/CodeGen/WebAssembly/phi.ll @@ -8,11 +8,11 @@ ; Basic phi triangle. ; CHECK-LABEL: test0: -; CHECK: @0{{$}} -; CHECK: set_local [[REG:@.*]], pop -; CHECK: sdiv [[REG]], {{.*}} +; CHECK: get_local 0{{$}} +; CHECK: set_local [[REG:.*]], pop +; CHECK: sdiv (get_local [[REG]]), {{.*}} ; CHECK: set_local [[REG]], pop -; CHECK: return [[REG]] +; CHECK: return (get_local [[REG]]) define i32 @test0(i32 %p) { entry: %t = icmp slt i32 %p, 0 @@ -29,9 +29,9 @@ ; CHECK-LABEL: test1: ; CHECK: BB1_1: -; CHECK: [[REG1:@.*]] -; CHECK: set_local [[REG0:@.*]], pop -; CHECK: [[REG2:@.*]] +; CHECK: get_local [[REG1:.*]] +; CHECK: set_local [[REG0:.*]], pop +; CHECK: get_local [[REG2:.*]] ; CHECK: set_local [[REG1]], pop ; CHECK: [[REG0]] ; CHECK: set_local [[REG2]], pop Index: test/CodeGen/WebAssembly/store-trunc.ll =================================================================== --- test/CodeGen/WebAssembly/store-trunc.ll +++ test/CodeGen/WebAssembly/store-trunc.ll @@ -6,7 +6,7 @@ target triple = "wasm32-unknown-unknown" ; CHECK-LABEL: trunc_i8_i32: -; CHECK: store_i8 @3, @2{{$}} +; CHECK: store_i8 (get_local 3), (get_local 2){{$}} define void @trunc_i8_i32(i8 *%p, i32 %v) { %t = trunc i32 %v to i8 store i8 %t, i8* %p @@ -14,7 +14,7 @@ } ; CHECK-LABEL: trunc_i16_i32: -; CHECK: store_i16 @3, @2{{$}} +; CHECK: store_i16 (get_local 3), (get_local 2){{$}} define void @trunc_i16_i32(i16 *%p, i32 %v) { %t = trunc i32 %v to i16 store i16 %t, i16* %p @@ -22,7 +22,7 @@ } ; CHECK-LABEL: trunc_i8_i64: -; CHECK: store_i8 @3, @2{{$}} +; CHECK: store_i8 (get_local 3), (get_local 2){{$}} define void @trunc_i8_i64(i8 *%p, i64 %v) { %t = trunc i64 %v to i8 store i8 %t, i8* %p @@ -30,7 +30,7 @@ } ; CHECK-LABEL: trunc_i16_i64: -; CHECK: store_i16 @3, @2{{$}} +; CHECK: store_i16 (get_local 3), (get_local 2){{$}} define void @trunc_i16_i64(i16 *%p, i64 %v) { %t = trunc i64 %v to i16 store i16 %t, i16* %p @@ -38,7 +38,7 @@ } ; CHECK-LABEL: trunc_i32_i64: -; CHECK: store_i32 @3, @2{{$}} +; CHECK: store_i32 (get_local 3), (get_local 2){{$}} define void @trunc_i32_i64(i32 *%p, i64 %v) { %t = trunc i64 %v to i32 store i32 %t, i32* %p Index: test/CodeGen/WebAssembly/store.ll =================================================================== --- test/CodeGen/WebAssembly/store.ll +++ test/CodeGen/WebAssembly/store.ll @@ -8,11 +8,12 @@ ; CHECK-LABEL: sti32: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: store_i32 @3, @2{{$}} +; CHECK-NEXT: .local i32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: store_i32 (get_local 3), (get_local 2){{$}} ; CHECK-NEXT: return{{$}} define void @sti32(i32 *%p, i32 %v) { store i32 %v, i32* %p @@ -22,11 +23,12 @@ ; CHECK-LABEL: sti64: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: store_i64 @3, @2{{$}} +; CHECK-NEXT: .local i64, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: store_i64 (get_local 3), (get_local 2){{$}} ; CHECK-NEXT: return{{$}} define void @sti64(i64 *%p, i64 %v) { store i64 %v, i64* %p @@ -36,11 +38,12 @@ ; CHECK-LABEL: stf32: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param f32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: store_f32 @3, @2{{$}} +; CHECK-NEXT: .local f32, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: store_f32 (get_local 3), (get_local 2){{$}} ; CHECK-NEXT: return{{$}} define void @stf32(float *%p, float %v) { store float %v, float* %p @@ -50,11 +53,12 @@ ; CHECK-LABEL: stf64: ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param f64{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @3, pop{{$}} -; CHECK-NEXT: store_f64 @3, @2{{$}} +; CHECK-NEXT: .local f64, i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 3, pop{{$}} +; CHECK-NEXT: store_f64 (get_local 3), (get_local 2){{$}} ; CHECK-NEXT: return{{$}} define void @stf64(double *%p, double %v) { store double %v, double* %p Index: test/CodeGen/WebAssembly/unused-argument.ll =================================================================== --- test/CodeGen/WebAssembly/unused-argument.ll +++ test/CodeGen/WebAssembly/unused-argument.ll @@ -9,9 +9,10 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @1{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32{{$}} +; CHECK-NEXT: get_local 1{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @unused_first(i32 %x, i32 %y) { ret i32 %y } @@ -20,9 +21,10 @@ ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .result i32{{$}} -; CHECK-NEXT: @0{{$}} -; CHECK-NEXT: set_local @2, pop{{$}} -; CHECK-NEXT: return @2{{$}} +; CHECK-NEXT: .local i32{{$}} +; CHECK-NEXT: get_local 0{{$}} +; CHECK-NEXT: set_local 2, pop{{$}} +; CHECK-NEXT: return (get_local 2){{$}} define i32 @unused_second(i32 %x, i32 %y) { ret i32 %x }