#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/MC/MCStreamer.h"
+#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
// AsmPrinter Implementation.
//===------------------------------------------------------------------===//
+ void EmitFunctionEntryLabel() override;
+ void EmitFunctionBodyStart() override;
+ void EmitFunctionBodyEnd() override;
+
void EmitInstruction(const MachineInstr *MI) override;
};
static std::string toSymbol(StringRef S) { return ("$" + S).str(); }
+static const char *toType(const Type *Ty) {
+ switch (Ty->getTypeID()) {
+ default: break;
+ case Type::FloatTyID: return "f32";
+ case Type::DoubleTyID: return "f64";
+ case Type::IntegerTyID:
+ switch (Ty->getIntegerBitWidth()) {
+ case 32: return "i32";
+ case 64: return "i64";
+ default: break;
+ }
+ }
+ DEBUG(dbgs() << "Invalid type "; Ty->print(dbgs()); dbgs() << '\n');
+ llvm_unreachable("invalid type");
+ return "<invalid>";
+}
+
+void WebAssemblyAsmPrinter::EmitFunctionEntryLabel() {
+ SmallString<128> Str;
+ raw_svector_ostream OS(Str);
+
+ CurrentFnSym->redefineIfPossible();
+
+ // The function label could have already been emitted if two symbols end up
+ // conflicting due to asm renaming. Detect this and emit an error.
+ if (CurrentFnSym->isVariable())
+ report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
+ "' is a protected alias");
+ if (CurrentFnSym->isDefined())
+ report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
+ "' label emitted multiple times to assembly file");
+
+ OS << "(func " << toSymbol(CurrentFnSym->getName());
+ OutStreamer->EmitRawText(OS.str());
+}
+
+void WebAssemblyAsmPrinter::EmitFunctionBodyStart() {
+ SmallString<128> Str;
+ raw_svector_ostream OS(Str);
+ const Function *F = MF->getFunction();
+ for (const Argument &A : F->args())
+ OS << " (param " << toType(A.getType()) << ')';
+ const Type *Rt = F->getReturnType();
+ if (!Rt->isVoidTy())
+ OS << " (result " << toType(Rt) << ')';
+ OS << '\n';
+ OutStreamer->EmitRawText(OS.str());
+}
+
+void WebAssemblyAsmPrinter::EmitFunctionBodyEnd() {
+ SmallString<128> Str;
+ raw_svector_ostream OS(Str);
+ OS << ") ;; end func " << toSymbol(CurrentFnSym->getName()) << '\n';
+ OutStreamer->EmitRawText(OS.str());
+}
+
void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) {
DEBUG(dbgs() << "EmitInstruction: " << *MI << '\n');
SmallString<128> Str;
declare float @float_nullary()
declare double @double_nullary()
-; CHECK-LABEL: call_i32_nullary:
+; CHECK-LABEL: (func $call_i32_nullary
+; CHECK-NEXT: (result i32)
; CHECK-NEXT: (setlocal @0 (global $i32_nullary))
; CHECK-NEXT: (setlocal @1 (call @0))
; CHECK-NEXT: (return @1)
ret i32 %r
}
-; CHECK-LABEL: call_i64_nullary:
+; CHECK-LABEL: (func $call_i64_nullary
+; CHECK-NEXT: (result i64)
; CHECK-NEXT: (setlocal @0 (global $i64_nullary))
; CHECK-NEXT: (setlocal @1 (call @0))
; CHECK-NEXT: (return @1)
ret i64 %r
}
-; CHECK-LABEL: call_float_nullary:
+; CHECK-LABEL: (func $call_float_nullary
+; CHECK-NEXT: (result f32)
; CHECK-NEXT: (setlocal @0 (global $float_nullary))
; CHECK-NEXT: (setlocal @1 (call @0))
; CHECK-NEXT: (return @1)
ret float %r
}
-; CHECK-LABEL: call_double_nullary:
+; CHECK-LABEL: (func $call_double_nullary
+; CHECK-NEXT: (result f64)
; CHECK-NEXT: (setlocal @0 (global $double_nullary))
; CHECK-NEXT: (setlocal @1 (call @0))
; CHECK-NEXT: (return @1)
ret double %r
}
-; CHECK-LABEL: call_i32_unary:
+; CHECK-LABEL: (func $call_i32_unary
+; CHECK-NEXT: (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (global $i32_unary))
; CHECK-NEXT: (setlocal @2 (call @1 @0))
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
-; CHECK-LABEL: ord_f32:
+; CHECK-LABEL: (func $ord_f32
+; CHECK-NEXT: (param f32) (param f32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (argument 1))
; CHECK-NEXT: (setlocal @2 (eq @1 @1))
ret i32 %b
}
-; CHECK-LABEL: uno_f32:
+; CHECK-LABEL: (func $uno_f32
+; CHECK-NEXT: (param f32) (param f32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (argument 1))
; CHECK-NEXT: (setlocal @2 (ne @1 @1))
ret i32 %b
}
-; CHECK-LABEL: oeq_f32:
+; CHECK-LABEL: (func $oeq_f32
+; CHECK-NEXT: (param f32) (param f32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (eq @1 @0))
ret i32 %b
}
-; CHECK-LABEL: une_f32:
+; CHECK-LABEL: (func $une_f32
; CHECK: (setlocal @2 (ne @1 @0))
define i32 @une_f32(float %x, float %y) {
%a = fcmp une float %x, %y
ret i32 %b
}
-; CHECK-LABEL: olt_f32:
+; CHECK-LABEL: (func $olt_f32
; CHECK: (setlocal @2 (lt @1 @0))
define i32 @olt_f32(float %x, float %y) {
%a = fcmp olt float %x, %y
ret i32 %b
}
-; CHECK-LABEL: ole_f32:
+; CHECK-LABEL: (func $ole_f32
; CHECK: (setlocal @2 (le @1 @0))
define i32 @ole_f32(float %x, float %y) {
%a = fcmp ole float %x, %y
ret i32 %b
}
-; CHECK-LABEL: ogt_f32:
+; CHECK-LABEL: (func $ogt_f32
; CHECK: (setlocal @2 (gt @1 @0))
define i32 @ogt_f32(float %x, float %y) {
%a = fcmp ogt float %x, %y
ret i32 %b
}
-; CHECK-LABEL: oge_f32:
+; CHECK-LABEL: (func $oge_f32
; CHECK: (setlocal @2 (ge @1 @0))
define i32 @oge_f32(float %x, float %y) {
%a = fcmp oge float %x, %y
; Expanded comparisons, which also check for NaN.
-; CHECK-LABEL: ueq_f32:
+; CHECK-LABEL: (func $ueq_f32
+; CHECK-NEXT: (param f32) (param f32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (eq @1 @0))
ret i32 %b
}
-; CHECK-LABEL: one_f32:
+; CHECK-LABEL: (func $one_f32
; CHECK: (setlocal @2 (ne @1 @0))
define i32 @one_f32(float %x, float %y) {
%a = fcmp one float %x, %y
ret i32 %b
}
-; CHECK-LABEL: ult_f32:
+; CHECK-LABEL: (func $ult_f32
; CHECK: (setlocal @2 (lt @1 @0))
define i32 @ult_f32(float %x, float %y) {
%a = fcmp ult float %x, %y
ret i32 %b
}
-; CHECK-LABEL: ule_f32:
+; CHECK-LABEL: (func $ule_f32
; CHECK: (setlocal @2 (le @1 @0))
define i32 @ule_f32(float %x, float %y) {
%a = fcmp ule float %x, %y
ret i32 %b
}
-; CHECK-LABEL: ugt_f32:
+; CHECK-LABEL: (func $ugt_f32
; CHECK: (setlocal @2 (gt @1 @0))
define i32 @ugt_f32(float %x, float %y) {
%a = fcmp ugt float %x, %y
ret i32 %b
}
-; CHECK-LABEL: uge_f32:
+; CHECK-LABEL: (func $uge_f32
; CHECK: (setlocal @2 (ge @1 @0))
define i32 @uge_f32(float %x, float %y) {
%a = fcmp uge float %x, %y
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
-; CHECK-LABEL: ord_f64:
+; CHECK-LABEL: (func $ord_f64
+; CHECK-NEXT: (param f64) (param f64) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (argument 1))
; CHECK-NEXT: (setlocal @2 (eq @1 @1))
ret i32 %b
}
-; CHECK-LABEL: uno_f64:
+; CHECK-LABEL: (func $uno_f64
+; CHECK-NEXT: (param f64) (param f64) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (argument 1))
; CHECK-NEXT: (setlocal @2 (ne @1 @1))
ret i32 %b
}
-; CHECK-LABEL: oeq_f64:
+; CHECK-LABEL: (func $oeq_f64
+; CHECK-NEXT: (param f64) (param f64) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (eq @1 @0))
ret i32 %b
}
-; CHECK-LABEL: une_f64:
+; CHECK-LABEL: (func $une_f64
; CHECK: (setlocal @2 (ne @1 @0))
define i32 @une_f64(double %x, double %y) {
%a = fcmp une double %x, %y
ret i32 %b
}
-; CHECK-LABEL: olt_f64:
+; CHECK-LABEL: (func $olt_f64
; CHECK: (setlocal @2 (lt @1 @0))
define i32 @olt_f64(double %x, double %y) {
%a = fcmp olt double %x, %y
ret i32 %b
}
-; CHECK-LABEL: ole_f64:
+; CHECK-LABEL: (func $ole_f64
; CHECK: (setlocal @2 (le @1 @0))
define i32 @ole_f64(double %x, double %y) {
%a = fcmp ole double %x, %y
ret i32 %b
}
-; CHECK-LABEL: ogt_f64:
+; CHECK-LABEL: (func $ogt_f64
; CHECK: (setlocal @2 (gt @1 @0))
define i32 @ogt_f64(double %x, double %y) {
%a = fcmp ogt double %x, %y
ret i32 %b
}
-; CHECK-LABEL: oge_f64:
+; CHECK-LABEL: (func $oge_f64
; CHECK: (setlocal @2 (ge @1 @0))
define i32 @oge_f64(double %x, double %y) {
%a = fcmp oge double %x, %y
; Expanded comparisons, which also check for NaN.
-; CHECK-LABEL: ueq_f64:
+; CHECK-LABEL: (func $ueq_f64
+; CHECK-NEXT: (param f64) (param f64) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (eq @1 @0))
ret i32 %b
}
-; CHECK-LABEL: one_f64:
+; CHECK-LABEL: (func $one_f64
; CHECK: (setlocal @2 (ne @1 @0))
define i32 @one_f64(double %x, double %y) {
%a = fcmp one double %x, %y
ret i32 %b
}
-; CHECK-LABEL: ult_f64:
+; CHECK-LABEL: (func $ult_f64
; CHECK: (setlocal @2 (lt @1 @0))
define i32 @ult_f64(double %x, double %y) {
%a = fcmp ult double %x, %y
ret i32 %b
}
-; CHECK-LABEL: ule_f64:
+; CHECK-LABEL: (func $ule_f64
; CHECK: (setlocal @2 (le @1 @0))
define i32 @ule_f64(double %x, double %y) {
%a = fcmp ule double %x, %y
ret i32 %b
}
-; CHECK-LABEL: ugt_f64:
+; CHECK-LABEL: (func $ugt_f64
; CHECK: (setlocal @2 (gt @1 @0))
define i32 @ugt_f64(double %x, double %y) {
%a = fcmp ugt double %x, %y
ret i32 %b
}
-; CHECK-LABEL: uge_f64:
+; CHECK-LABEL: (func $uge_f64
; CHECK: (setlocal @2 (ge @1 @0))
define i32 @uge_f64(double %x, double %y) {
%a = fcmp uge double %x, %y
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
-; CHECK-LABEL: eq_i32:
+; CHECK-LABEL: (func $eq_i32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (eq @1 @0))
ret i32 %b
}
-; CHECK-LABEL: ne_i32:
+; CHECK-LABEL: (func $ne_i32
; CHECK: (setlocal @2 (ne @1 @0))
define i32 @ne_i32(i32 %x, i32 %y) {
%a = icmp ne i32 %x, %y
ret i32 %b
}
-; CHECK-LABEL: slt_i32:
+; CHECK-LABEL: (func $slt_i32
; CHECK: (setlocal @2 (slt @1 @0))
define i32 @slt_i32(i32 %x, i32 %y) {
%a = icmp slt i32 %x, %y
ret i32 %b
}
-; CHECK-LABEL: sle_i32:
+; CHECK-LABEL: (func $sle_i32
; CHECK: (setlocal @2 (sle @1 @0))
define i32 @sle_i32(i32 %x, i32 %y) {
%a = icmp sle i32 %x, %y
ret i32 %b
}
-; CHECK-LABEL: ult_i32:
+; CHECK-LABEL: (func $ult_i32
; CHECK: (setlocal @2 (ult @1 @0))
define i32 @ult_i32(i32 %x, i32 %y) {
%a = icmp ult i32 %x, %y
ret i32 %b
}
-; CHECK-LABEL: ule_i32:
+; CHECK-LABEL: (func $ule_i32
; CHECK: (setlocal @2 (ule @1 @0))
define i32 @ule_i32(i32 %x, i32 %y) {
%a = icmp ule i32 %x, %y
ret i32 %b
}
-; CHECK-LABEL: sgt_i32:
+; CHECK-LABEL: (func $sgt_i32
; CHECK: (setlocal @2 (sgt @1 @0))
define i32 @sgt_i32(i32 %x, i32 %y) {
%a = icmp sgt i32 %x, %y
ret i32 %b
}
-; CHECK-LABEL: sge_i32:
+; CHECK-LABEL: (func $sge_i32
; CHECK: (setlocal @2 (sge @1 @0))
define i32 @sge_i32(i32 %x, i32 %y) {
%a = icmp sge i32 %x, %y
ret i32 %b
}
-; CHECK-LABEL: ugt_i32:
+; CHECK-LABEL: (func $ugt_i32
; CHECK: (setlocal @2 (ugt @1 @0))
define i32 @ugt_i32(i32 %x, i32 %y) {
%a = icmp ugt i32 %x, %y
ret i32 %b
}
-; CHECK-LABEL: uge_i32:
+; CHECK-LABEL: (func $uge_i32
; CHECK: (setlocal @2 (uge @1 @0))
define i32 @uge_i32(i32 %x, i32 %y) {
%a = icmp uge i32 %x, %y
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
-; CHECK-LABEL: eq_i64:
+; CHECK-LABEL: (func $eq_i64
+; CHECK-NEXT: (param i64) (param i64) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (eq @1 @0))
ret i32 %b
}
-; CHECK-LABEL: ne_i64:
+; CHECK-LABEL: (func $ne_i64
; CHECK: (setlocal @2 (ne @1 @0))
define i32 @ne_i64(i64 %x, i64 %y) {
%a = icmp ne i64 %x, %y
ret i32 %b
}
-; CHECK-LABEL: slt_i64:
+; CHECK-LABEL: (func $slt_i64
; CHECK: (setlocal @2 (slt @1 @0))
define i32 @slt_i64(i64 %x, i64 %y) {
%a = icmp slt i64 %x, %y
ret i32 %b
}
-; CHECK-LABEL: sle_i64:
+; CHECK-LABEL: (func $sle_i64
; CHECK: (setlocal @2 (sle @1 @0))
define i32 @sle_i64(i64 %x, i64 %y) {
%a = icmp sle i64 %x, %y
ret i32 %b
}
-; CHECK-LABEL: ult_i64:
+; CHECK-LABEL: (func $ult_i64
; CHECK: (setlocal @2 (ult @1 @0))
define i32 @ult_i64(i64 %x, i64 %y) {
%a = icmp ult i64 %x, %y
ret i32 %b
}
-; CHECK-LABEL: ule_i64:
+; CHECK-LABEL: (func $ule_i64
; CHECK: (setlocal @2 (ule @1 @0))
define i32 @ule_i64(i64 %x, i64 %y) {
%a = icmp ule i64 %x, %y
ret i32 %b
}
-; CHECK-LABEL: sgt_i64:
+; CHECK-LABEL: (func $sgt_i64
; CHECK: (setlocal @2 (sgt @1 @0))
define i32 @sgt_i64(i64 %x, i64 %y) {
%a = icmp sgt i64 %x, %y
ret i32 %b
}
-; CHECK-LABEL: sge_i64:
+; CHECK-LABEL: (func $sge_i64
; CHECK: (setlocal @2 (sge @1 @0))
define i32 @sge_i64(i64 %x, i64 %y) {
%a = icmp sge i64 %x, %y
ret i32 %b
}
-; CHECK-LABEL: ugt_i64:
+; CHECK-LABEL: (func $ugt_i64
; CHECK: (setlocal @2 (ugt @1 @0))
define i32 @ugt_i64(i64 %x, i64 %y) {
%a = icmp ugt i64 %x, %y
ret i32 %b
}
-; CHECK-LABEL: uge_i64:
+; CHECK-LABEL: (func $uge_i64
; CHECK: (setlocal @2 (uge @1 @0))
define i32 @uge_i64(i64 %x, i64 %y) {
%a = icmp uge i64 %x, %y
; This tests very minimal fast-isel functionality.
-; CHECK-LABEL: immediate_f32
+; CHECK-LABEL: (func $immediate_f32
; CHECK: (immediate 0x1.4p1)
define float @immediate_f32() {
ret float 2.5
}
-; CHECK-LABEL: immediate_f64
+; CHECK-LABEL: (func $immediate_f64
; CHECK: (immediate 0x1.4p1)
define double @immediate_f64() {
ret double 2.5
declare float @llvm.nearbyint.f32(float)
declare float @llvm.rint.f32(float)
-; CHECK-LABEL: fadd32:
+; CHECK-LABEL: (func $fadd32
+; CHECK-NEXT: (param f32) (param f32) (result f32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (fadd @1 @0))
ret float %a
}
-; CHECK-LABEL: fsub32:
+; CHECK-LABEL: (func $fsub32
; CHECK: (setlocal @2 (fsub @1 @0))
define float @fsub32(float %x, float %y) {
%a = fsub float %x, %y
ret float %a
}
-; CHECK-LABEL: fmul32:
+; CHECK-LABEL: (func $fmul32
; CHECK: (setlocal @2 (fmul @1 @0))
define float @fmul32(float %x, float %y) {
%a = fmul float %x, %y
ret float %a
}
-; CHECK-LABEL: fdiv32:
+; CHECK-LABEL: (func $fdiv32
; CHECK: (setlocal @2 (fdiv @1 @0))
define float @fdiv32(float %x, float %y) {
%a = fdiv float %x, %y
ret float %a
}
-; CHECK-LABEL: fabs32:
+; CHECK-LABEL: (func $fabs32
; CHECK: (setlocal @1 (fabs @0))
define float @fabs32(float %x) {
%a = call float @llvm.fabs.f32(float %x)
ret float %a
}
-; CHECK-LABEL: fneg32:
+; CHECK-LABEL: (func $fneg32
; CHECK: (setlocal @1 (fneg @0))
define float @fneg32(float %x) {
%a = fsub float -0., %x
ret float %a
}
-; CHECK-LABEL: copysign32:
+; CHECK-LABEL: (func $copysign32
; CHECK: (setlocal @2 (copysign @1 @0))
define float @copysign32(float %x, float %y) {
%a = call float @llvm.copysign.f32(float %x, float %y)
ret float %a
}
-; CHECK-LABEL: sqrt32:
+; CHECK-LABEL: (func $sqrt32
; CHECK: (setlocal @1 (sqrt @0))
define float @sqrt32(float %x) {
%a = call float @llvm.sqrt.f32(float %x)
ret float %a
}
-; CHECK-LABEL: ceil32:
+; CHECK-LABEL: (func $ceil32
; CHECK: (setlocal @1 (ceil @0))
define float @ceil32(float %x) {
%a = call float @llvm.ceil.f32(float %x)
ret float %a
}
-; CHECK-LABEL: floor32:
+; CHECK-LABEL: (func $floor32
; CHECK: (setlocal @1 (floor @0))
define float @floor32(float %x) {
%a = call float @llvm.floor.f32(float %x)
ret float %a
}
-; CHECK-LABEL: trunc32:
+; CHECK-LABEL: (func $trunc32
; CHECK: (setlocal @1 (trunc @0))
define float @trunc32(float %x) {
%a = call float @llvm.trunc.f32(float %x)
ret float %a
}
-; CHECK-LABEL: nearestint32:
+; CHECK-LABEL: (func $nearestint32
; CHECK: (setlocal @1 (nearestint @0))
define float @nearestint32(float %x) {
%a = call float @llvm.nearbyint.f32(float %x)
ret float %a
}
-; CHECK-LABEL: nearestint32_via_rint:
+; CHECK-LABEL: (func $nearestint32_via_rint
; CHECK: (setlocal @1 (nearestint @0))
define float @nearestint32_via_rint(float %x) {
%a = call float @llvm.rint.f32(float %x)
declare double @llvm.nearbyint.f64(double)
declare double @llvm.rint.f64(double)
-; CHECK-LABEL: fadd64:
+; CHECK-LABEL: (func $fadd64
+; CHECK-NEXT: (param f64) (param f64) (result f64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (fadd @1 @0))
ret double %a
}
-; CHECK-LABEL: fsub64:
+; CHECK-LABEL: (func $fsub64
; CHECK: (setlocal @2 (fsub @1 @0))
define double @fsub64(double %x, double %y) {
%a = fsub double %x, %y
ret double %a
}
-; CHECK-LABEL: fmul64:
+; CHECK-LABEL: (func $fmul64
; CHECK: (setlocal @2 (fmul @1 @0))
define double @fmul64(double %x, double %y) {
%a = fmul double %x, %y
ret double %a
}
-; CHECK-LABEL: fdiv64:
+; CHECK-LABEL: (func $fdiv64
; CHECK: (setlocal @2 (fdiv @1 @0))
define double @fdiv64(double %x, double %y) {
%a = fdiv double %x, %y
ret double %a
}
-; CHECK-LABEL: fabs64:
+; CHECK-LABEL: (func $fabs64
; CHECK: (setlocal @1 (fabs @0))
define double @fabs64(double %x) {
%a = call double @llvm.fabs.f64(double %x)
ret double %a
}
-; CHECK-LABEL: fneg64:
+; CHECK-LABEL: (func $fneg64
; CHECK: (setlocal @1 (fneg @0))
define double @fneg64(double %x) {
%a = fsub double -0., %x
ret double %a
}
-; CHECK-LABEL: copysign64:
+; CHECK-LABEL: (func $copysign64
; CHECK: (setlocal @2 (copysign @1 @0))
define double @copysign64(double %x, double %y) {
%a = call double @llvm.copysign.f64(double %x, double %y)
ret double %a
}
-; CHECK-LABEL: sqrt64:
+; CHECK-LABEL: (func $sqrt64
; CHECK: (setlocal @1 (sqrt @0))
define double @sqrt64(double %x) {
%a = call double @llvm.sqrt.f64(double %x)
ret double %a
}
-; CHECK-LABEL: ceil64:
+; CHECK-LABEL: (func $ceil64
; CHECK: (setlocal @1 (ceil @0))
define double @ceil64(double %x) {
%a = call double @llvm.ceil.f64(double %x)
ret double %a
}
-; CHECK-LABEL: floor64:
+; CHECK-LABEL: (func $floor64
; CHECK: (setlocal @1 (floor @0))
define double @floor64(double %x) {
%a = call double @llvm.floor.f64(double %x)
ret double %a
}
-; CHECK-LABEL: trunc64:
+; CHECK-LABEL: (func $trunc64
; CHECK: (setlocal @1 (trunc @0))
define double @trunc64(double %x) {
%a = call double @llvm.trunc.f64(double %x)
ret double %a
}
-; CHECK-LABEL: nearestint64:
+; CHECK-LABEL: (func $nearestint64
; CHECK: (setlocal @1 (nearestint @0))
define double @nearestint64(double %x) {
%a = call double @llvm.nearbyint.f64(double %x)
ret double %a
}
-; CHECK-LABEL: nearestint64_via_rint:
+; CHECK-LABEL: (func $nearestint64_via_rint
; CHECK: (setlocal @1 (nearestint @0))
define double @nearestint64_via_rint(double %x) {
%a = call double @llvm.rint.f64(double %x)
--- /dev/null
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+; Test that basic functions assemble as expected.
+
+target datalayout = "e-p:32:32-i64:64-v128:8:128-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+; CHECK-LABEL: (func $f0{{$}}
+; CHECK: (return){{$}}
+; CHECK-NEXT: ) ;; end func $f0{{$}}
+define void @f0() {
+ ret void
+}
+
+; CHECK-LABEL: (func $f1{{$}}
+; CHECK-NEXT: (result i32){{$}}
+; CHECK-NEXT: (setlocal @0 (immediate 0)){{$}}
+; CHECK-NEXT: (return @0){{$}}
+; CHECK-NEXT: ) ;; end func $f1{{$}}
+define i32 @f1() {
+ ret i32 0
+}
+
+; CHECK-LABEL: (func $f2{{$}}
+; CHECK-NEXT: (param i32) (param f32) (result i32){{$}}
+; CHECK-NEXT: (setlocal @0 (immediate 0)){{$}}
+; CHECK-NEXT: (return @0){{$}}
+; CHECK-NEXT: ) ;; end func $f2{{$}}
+define i32 @f2(i32 %p1, float %p2) {
+ ret i32 0
+}
+
+; CHECK-LABEL: (func $f3{{$}}
+; CHECK-NEXT: (param i32) (param f32){{$}}
+; CHECK-NEXT: (return){{$}}
+; CHECK-NEXT: ) ;; end func $f3{{$}}
+define void @f3(i32 %p1, float %p2) {
+ ret void
+}
; CHECK-NOT: globl
; CHECK: ;; .globl foo
; CHECK-NOT: globl
-; CHECK-LABEL: foo:
+; CHECK-LABEL: (func $foo
define void @foo() {
ret void
}
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
-; CHECK-LABEL: zero_i32:
+; CHECK-LABEL: (func $zero_i32
+; CHECK-NEXT: (result i32)
; CHECK-NEXT: (setlocal @0 (immediate 0))
; CHECK-NEXT: (return @0)
define i32 @zero_i32() {
ret i32 0
}
-; CHECK-LABEL: one_i32:
+; CHECK-LABEL: (func $one_i32
+; CHECK-NEXT: (result i32)
; CHECK-NEXT: (setlocal @0 (immediate 1))
; CHECK-NEXT: (return @0)
define i32 @one_i32() {
ret i32 1
}
-; CHECK-LABEL: max_i32:
+; CHECK-LABEL: (func $max_i32
+; CHECK-NEXT: (result i32)
; CHECK-NEXT: (setlocal @0 (immediate 2147483647))
; CHECK-NEXT: (return @0)
define i32 @max_i32() {
ret i32 2147483647
}
-; CHECK-LABEL: min_i32:
+; CHECK-LABEL: (func $min_i32
+; CHECK-NEXT: (result i32)
; CHECK-NEXT: (setlocal @0 (immediate -2147483648))
; CHECK-NEXT: (return @0)
define i32 @min_i32() {
ret i32 -2147483648
}
-; CHECK-LABEL: zero_i64:
+; CHECK-LABEL: (func $zero_i64
+; CHECK-NEXT: (result i64)
; CHECK-NEXT: (setlocal @0 (immediate 0))
; CHECK-NEXT: (return @0)
define i64 @zero_i64() {
ret i64 0
}
-; CHECK-LABEL: one_i64:
+; CHECK-LABEL: (func $one_i64
+; CHECK-NEXT: (result i64)
; CHECK-NEXT: (setlocal @0 (immediate 1))
; CHECK-NEXT: (return @0)
define i64 @one_i64() {
ret i64 1
}
-; CHECK-LABEL: max_i64:
+; CHECK-LABEL: (func $max_i64
+; CHECK-NEXT: (result i64)
; CHECK-NEXT: (setlocal @0 (immediate 9223372036854775807))
; CHECK-NEXT: (return @0)
define i64 @max_i64() {
ret i64 9223372036854775807
}
-; CHECK-LABEL: min_i64:
+; CHECK-LABEL: (func $min_i64
+; CHECK-NEXT: (result i64)
; CHECK-NEXT: (setlocal @0 (immediate -9223372036854775808))
; CHECK-NEXT: (return @0)
define i64 @min_i64() {
ret i64 -9223372036854775808
}
-; CHECK-LABEL: negzero_f32:
+; CHECK-LABEL: (func $negzero_f32
+; CHECK-NEXT: (result f32)
; CHECK-NEXT: (setlocal @0 (immediate -0x0p0))
; CHECK-NEXT: (return @0)
define float @negzero_f32() {
ret float -0.0
}
-; CHECK-LABEL: zero_f32:
+; CHECK-LABEL: (func $zero_f32
+; CHECK-NEXT: (result f32)
; CHECK-NEXT: (setlocal @0 (immediate 0x0p0))
; CHECK-NEXT: (return @0)
define float @zero_f32() {
ret float 0.0
}
-; CHECK-LABEL: one_f32:
+; CHECK-LABEL: (func $one_f32
+; CHECK-NEXT: (result f32)
; CHECK-NEXT: (setlocal @0 (immediate 0x1p0))
; CHECK-NEXT: (return @0)
define float @one_f32() {
ret float 1.0
}
-; CHECK-LABEL: two_f32:
+; CHECK-LABEL: (func $two_f32
+; CHECK-NEXT: (result f32)
; CHECK-NEXT: (setlocal @0 (immediate 0x1p1))
; CHECK-NEXT: (return @0)
define float @two_f32() {
ret float 2.0
}
-; CHECK-LABEL: nan_f32:
+; CHECK-LABEL: (func $nan_f32
+; CHECK-NEXT: (result f32)
; CHECK-NEXT: (setlocal @0 (immediate nan))
; CHECK-NEXT: (return @0)
define float @nan_f32() {
ret float 0x7FF8000000000000
}
-; CHECK-LABEL: negnan_f32:
+; CHECK-LABEL: (func $negnan_f32
+; CHECK-NEXT: (result f32)
; CHECK-NEXT: (setlocal @0 (immediate -nan))
; CHECK-NEXT: (return @0)
define float @negnan_f32() {
ret float 0xFFF8000000000000
}
-; CHECK-LABEL: inf_f32:
+; CHECK-LABEL: (func $inf_f32
+; CHECK-NEXT: (result f32)
; CHECK-NEXT: (setlocal @0 (immediate infinity))
; CHECK-NEXT: (return @0)
define float @inf_f32() {
ret float 0x7FF0000000000000
}
-; CHECK-LABEL: neginf_f32:
+; CHECK-LABEL: (func $neginf_f32
+; CHECK-NEXT: (result f32)
; CHECK-NEXT: (setlocal @0 (immediate -infinity))
; CHECK-NEXT: (return @0)
define float @neginf_f32() {
ret float 0xFFF0000000000000
}
-; CHECK-LABEL: negzero_f64:
+; CHECK-LABEL: (func $negzero_f64
+; CHECK-NEXT: (result f64)
; CHECK-NEXT: (setlocal @0 (immediate -0x0p0))
; CHECK-NEXT: (return @0)
define double @negzero_f64() {
ret double -0.0
}
-; CHECK-LABEL: zero_f64:
+; CHECK-LABEL: (func $zero_f64
+; CHECK-NEXT: (result f64)
; CHECK-NEXT: (setlocal @0 (immediate 0x0p0))
; CHECK-NEXT: (return @0)
define double @zero_f64() {
ret double 0.0
}
-; CHECK-LABEL: one_f64:
+; CHECK-LABEL: (func $one_f64
+; CHECK-NEXT: (result f64)
; CHECK-NEXT: (setlocal @0 (immediate 0x1p0))
; CHECK-NEXT: (return @0)
define double @one_f64() {
ret double 1.0
}
-; CHECK-LABEL: two_f64:
+; CHECK-LABEL: (func $two_f64
+; CHECK-NEXT: (result f64)
; CHECK-NEXT: (setlocal @0 (immediate 0x1p1))
; CHECK-NEXT: (return @0)
define double @two_f64() {
ret double 2.0
}
-; CHECK-LABEL: nan_f64:
+; CHECK-LABEL: (func $nan_f64
+; CHECK-NEXT: (result f64)
; CHECK-NEXT: (setlocal @0 (immediate nan))
; CHECK-NEXT: (return @0)
define double @nan_f64() {
ret double 0x7FF8000000000000
}
-; CHECK-LABEL: negnan_f64:
+; CHECK-LABEL: (func $negnan_f64
+; CHECK-NEXT: (result f64)
; CHECK-NEXT: (setlocal @0 (immediate -nan))
; CHECK-NEXT: (return @0)
define double @negnan_f64() {
ret double 0xFFF8000000000000
}
-; CHECK-LABEL: inf_f64:
+; CHECK-LABEL: (func $inf_f64
+; CHECK-NEXT: (result f64)
; CHECK-NEXT: (setlocal @0 (immediate infinity))
; CHECK-NEXT: (return @0)
define double @inf_f64() {
ret double 0x7FF0000000000000
}
-; CHECK-LABEL: neginf_f64:
+; CHECK-LABEL: (func $neginf_f64
+; CHECK-NEXT: (result f64)
; CHECK-NEXT: (setlocal @0 (immediate -infinity))
; CHECK-NEXT: (return @0)
define double @neginf_f64() {
declare i32 @llvm.cttz.i32(i32, i1)
declare i32 @llvm.ctpop.i32(i32)
-; CHECK-LABEL: add32:
+; CHECK-LABEL: (func $add32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (add @1 @0))
ret i32 %a
}
-; CHECK-LABEL: sub32:
+; CHECK-LABEL: (func $sub32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (sub @1 @0))
ret i32 %a
}
-; CHECK-LABEL: mul32:
+; CHECK-LABEL: (func $mul32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (mul @1 @0))
ret i32 %a
}
-; CHECK-LABEL: sdiv32:
+; CHECK-LABEL: (func $sdiv32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (sdiv @1 @0))
ret i32 %a
}
-; CHECK-LABEL: udiv32:
+; CHECK-LABEL: (func $udiv32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (udiv @1 @0))
ret i32 %a
}
-; CHECK-LABEL: srem32:
+; CHECK-LABEL: (func $srem32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (srem @1 @0))
ret i32 %a
}
-; CHECK-LABEL: urem32:
+; CHECK-LABEL: (func $urem32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (urem @1 @0))
ret i32 %a
}
-; CHECK-LABEL: and32:
+; CHECK-LABEL: (func $and32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (and @1 @0))
ret i32 %a
}
-; CHECK-LABEL: ior32:
+; CHECK-LABEL: (func $ior32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (ior @1 @0))
ret i32 %a
}
-; CHECK-LABEL: xor32:
+; CHECK-LABEL: (func $xor32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (xor @1 @0))
ret i32 %a
}
-; CHECK-LABEL: shl32:
+; CHECK-LABEL: (func $shl32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (shl @1 @0))
ret i32 %a
}
-; CHECK-LABEL: shr32:
+; CHECK-LABEL: (func $shr32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (shr @1 @0))
ret i32 %a
}
-; CHECK-LABEL: sar32:
+; CHECK-LABEL: (func $sar32
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (sar @1 @0))
ret i32 %a
}
-; CHECK-LABEL: clz32:
+; CHECK-LABEL: (func $clz32
+; CHECK-NEXT: (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (clz @0))
; CHECK-NEXT: (return @1)
ret i32 %a
}
-; CHECK-LABEL: clz32_zero_undef:
+; CHECK-LABEL: (func $clz32_zero_undef
+; CHECK-NEXT: (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (clz @0))
; CHECK-NEXT: (return @1)
ret i32 %a
}
-; CHECK-LABEL: ctz32:
+; CHECK-LABEL: (func $ctz32
+; CHECK-NEXT: (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (ctz @0))
; CHECK-NEXT: (return @1)
ret i32 %a
}
-; CHECK-LABEL: ctz32_zero_undef:
+; CHECK-LABEL: (func $ctz32_zero_undef
+; CHECK-NEXT: (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (ctz @0))
; CHECK-NEXT: (return @1)
ret i32 %a
}
-; CHECK-LABEL: popcnt32:
+; CHECK-LABEL: (func $popcnt32
+; CHECK-NEXT: (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (popcnt @0))
; CHECK-NEXT: (return @1)
declare i64 @llvm.cttz.i64(i64, i1)
declare i64 @llvm.ctpop.i64(i64)
-; CHECK-LABEL: add64:
+; CHECK-LABEL: (func $add64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (add @1 @0))
ret i64 %a
}
-; CHECK-LABEL: sub64:
+; CHECK-LABEL: (func $sub64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (sub @1 @0))
ret i64 %a
}
-; CHECK-LABEL: mul64:
+; CHECK-LABEL: (func $mul64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (mul @1 @0))
ret i64 %a
}
-; CHECK-LABEL: sdiv64:
+; CHECK-LABEL: (func $sdiv64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (sdiv @1 @0))
ret i64 %a
}
-; CHECK-LABEL: udiv64:
+; CHECK-LABEL: (func $udiv64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (udiv @1 @0))
ret i64 %a
}
-; CHECK-LABEL: srem64:
+; CHECK-LABEL: (func $srem64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (srem @1 @0))
ret i64 %a
}
-; CHECK-LABEL: urem64:
+; CHECK-LABEL: (func $urem64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (urem @1 @0))
ret i64 %a
}
-; CHECK-LABEL: and64:
+; CHECK-LABEL: (func $and64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (and @1 @0))
ret i64 %a
}
-; CHECK-LABEL: ior64:
+; CHECK-LABEL: (func $ior64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (ior @1 @0))
ret i64 %a
}
-; CHECK-LABEL: xor64:
+; CHECK-LABEL: (func $xor64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (xor @1 @0))
ret i64 %a
}
-; CHECK-LABEL: shl64:
+; CHECK-LABEL: (func $shl64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (shl @1 @0))
ret i64 %a
}
-; CHECK-LABEL: shr64:
+; CHECK-LABEL: (func $shr64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (shr @1 @0))
ret i64 %a
}
-; CHECK-LABEL: sar64:
+; CHECK-LABEL: (func $sar64
+; CHECK-NEXT: (param i64) (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (setlocal @1 (argument 0))
; CHECK-NEXT: (setlocal @2 (sar @1 @0))
ret i64 %a
}
-; CHECK-LABEL: clz64:
+; CHECK-LABEL: (func $clz64
+; CHECK-NEXT: (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (clz @0))
; CHECK-NEXT: (return @1)
ret i64 %a
}
-; CHECK-LABEL: clz64_zero_undef:
+; CHECK-LABEL: (func $clz64_zero_undef
+; CHECK-NEXT: (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (clz @0))
; CHECK-NEXT: (return @1)
ret i64 %a
}
-; CHECK-LABEL: ctz64:
+; CHECK-LABEL: (func $ctz64
+; CHECK-NEXT: (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (ctz @0))
; CHECK-NEXT: (return @1)
ret i64 %a
}
-; CHECK-LABEL: ctz64_zero_undef:
+; CHECK-LABEL: (func $ctz64_zero_undef
+; CHECK-NEXT: (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (ctz @0))
; CHECK-NEXT: (return @1)
ret i64 %a
}
-; CHECK-LABEL: popcnt64:
+; CHECK-LABEL: (func $popcnt64
+; CHECK-NEXT: (param i64) (result i64)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (popcnt @0))
; CHECK-NEXT: (return @1)
declare i32 @llvm.wasm.page.size.i32() nounwind readnone
-; CHECK-LABEL: page_size:
+; CHECK-LABEL: (func $page_size
+; CHECK-NEXT: (result i32)
; CHECK-NEXT: (setlocal @0 (page_size))
; CHECK-NEXT: (return @0)
define i32 @page_size() {
declare i64 @llvm.wasm.page.size.i64() nounwind readnone
-; CHECK-LABEL: page_size:
+; CHECK-LABEL: (func $page_size
+; CHECK-NEXT: (result i64)
; CHECK-NEXT: (setlocal @0 (page_size))
; CHECK-NEXT: (return @0)
define i64 @page_size() {
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
-; CHECK-LABEL: return_void:
-; CHECK-NEXT: (return)
+; CHECK-LABEL: (func $return_void
+; CHECK: (return)
define void @return_void() {
ret void
}
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
-; CHECK-LABEL: unused_first:
+; CHECK-LABEL: (func $unused_first
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 1))
; CHECK-NEXT: (return @0)
define i32 @unused_first(i32 %x, i32 %y) {
ret i32 %y
}
-; CHECK-LABEL: unused_second:
+; CHECK-LABEL: (func $unused_second
+; CHECK-NEXT: (param i32) (param i32) (result i32)
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (return @0)
define i32 @unused_second(i32 %x, i32 %y) {