1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 13:11:39 +01:00
llvm-mirror/test/CodeGen/WebAssembly/offset-folding.ll
Wouter van Oortmerssen e2177a8321 [WebAssembly] replaced .param/.result by .functype
Summary:
This makes it easier/cleaner to generate a single signature from
this directive. Also:
- Adds the symbol name, such that we don't depend on the location
  of this directive anymore.
- Actually constructs the signature in the assembler, and make the
  assembler own it.
- Refactor the use of MVT vs ValType in the streamer and assembler
  to require less conversions overall.
- Changed 700 or so tests to use it.

Reviewers: sbc100, dschuff

Subscribers: jgravelle-google, eraman, aheejin, sunfish, jfb, llvm-commits

Differential Revision: https://reviews.llvm.org/D54652

llvm-svn: 347228
2018-11-19 17:10:36 +00:00

64 lines
1.8 KiB
LLVM

; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s
; Test that constant offsets can be folded into global addresses.
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
@x = external global [0 x i32]
@y = global [50 x i32] zeroinitializer
; Test basic constant offsets of both defined and external symbols.
; CHECK-LABEL: test0:
; CHECK-NEXT: .functype test0 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, x+188{{$}}
; CHECK=NEXT: return $pop0{{$}}
define i32* @test0() {
ret i32* getelementptr ([0 x i32], [0 x i32]* @x, i32 0, i32 47)
}
; CHECK-LABEL: test1:
; CHECK-NEXT: .functype test1 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, y+188{{$}}
; CHECK=NEXT: return $pop0{{$}}
define i32* @test1() {
ret i32* getelementptr ([50 x i32], [50 x i32]* @y, i32 0, i32 47)
}
; Test zero offsets.
; CHECK-LABEL: test2:
; CHECK-NEXT: .functype test2 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, x{{$}}
; CHECK=NEXT: return $pop0{{$}}
define i32* @test2() {
ret i32* getelementptr ([0 x i32], [0 x i32]* @x, i32 0, i32 0)
}
; CHECK-LABEL: test3:
; CHECK-NEXT: .functype test3 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, y{{$}}
; CHECK=NEXT: return $pop0{{$}}
define i32* @test3() {
ret i32* getelementptr ([50 x i32], [50 x i32]* @y, i32 0, i32 0)
}
; Test negative offsets.
; CHECK-LABEL: test4:
; CHECK-NEXT: .functype test4 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, x-188{{$}}
; CHECK=NEXT: return $pop0{{$}}
define i32* @test4() {
ret i32* getelementptr ([0 x i32], [0 x i32]* @x, i32 0, i32 -47)
}
; CHECK-LABEL: test5:
; CHECK-NEXT: .functype test5 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, y-188{{$}}
; CHECK=NEXT: return $pop0{{$}}
define i32* @test5() {
ret i32* getelementptr ([50 x i32], [50 x i32]* @y, i32 0, i32 -47)
}