Andy Ayers | 9e5c851 | 2015-05-14 01:10:41 +0000 | [diff] [blame] | 1 | ; Verify the assembler produces the expected expressions |
| 2 | ; RUN: llc -mtriple=x86_64-pc-win32 %s -o - | FileCheck %s |
Andy Ayers | 9e5c851 | 2015-05-14 01:10:41 +0000 | [diff] [blame] | 3 | |
| 4 | ;;;; some globals |
| 5 | |
| 6 | @g1 = constant i32 1; |
| 7 | @g2 = constant i32 2; |
| 8 | @g3 = constant i32 3; |
| 9 | @g4 = constant i32 4; |
| 10 | @__ImageBase = external global i64*; |
| 11 | |
| 12 | ;;;; cross-section relative relocations |
| 13 | |
| 14 | ; CHECK: .quad (g3-t1)+4 |
| 15 | @t1 = global i64 add(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i64* @t1 to i64)), i64 4), section ".fix" |
| 16 | ; CHECK: .quad g3-t2 |
| 17 | @t2 = global i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i64* @t2 to i64)), section ".fix" |
| 18 | ; CHECK: .quad (g3-t3)-4 |
| 19 | @t3 = global i64 sub(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i64* @t3 to i64)), i64 4), section ".fix" |
| 20 | ; CHECK: .long g3-t4 |
| 21 | @t4 = global i32 trunc(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i32* @t4 to i64)) to i32), section ".fix" |
| 22 | |
| 23 | ;;;; image base relocation |
| 24 | |
Peter Collingbourne | 265ebd7 | 2016-04-22 20:40:10 +0000 | [diff] [blame] | 25 | ; CHECK: .long g3@IMGREL{{$}} |
Andy Ayers | 9e5c851 | 2015-05-14 01:10:41 +0000 | [diff] [blame] | 26 | @t5 = global i32 trunc(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i64** @__ImageBase to i64)) to i32), section ".fix" |
| 27 | |
Peter Collingbourne | 265ebd7 | 2016-04-22 20:40:10 +0000 | [diff] [blame] | 28 | ; CHECK: .long g3@IMGREL+4{{$}} |
| 29 | @t6 = global i32 trunc(i64 sub(i64 ptrtoint(i32* getelementptr (i32, i32* @g3, i32 1) to i64), i64 ptrtoint(i64** @__ImageBase to i64)) to i32), section ".fix" |
| 30 | |
Andy Ayers | 9e5c851 | 2015-05-14 01:10:41 +0000 | [diff] [blame] | 31 | ;;;; cross-section relative with source offset |
| 32 | |
| 33 | %struct.EEType = type { [2 x i8], i64, i32} |
| 34 | |
Peter Collingbourne | 265ebd7 | 2016-04-22 20:40:10 +0000 | [diff] [blame] | 35 | ; CHECK: .long (g3-t7)-16 |
| 36 | @t7 = global %struct.EEType { |
Andy Ayers | 9e5c851 | 2015-05-14 01:10:41 +0000 | [diff] [blame] | 37 | [2 x i8] c"\01\02", |
| 38 | i64 256, |
Peter Collingbourne | 265ebd7 | 2016-04-22 20:40:10 +0000 | [diff] [blame] | 39 | i32 trunc(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i32* getelementptr inbounds (%struct.EEType, %struct.EEType* @t7, i32 0, i32 2) to i64)) to i32 ) |
Andy Ayers | 9e5c851 | 2015-05-14 01:10:41 +0000 | [diff] [blame] | 40 | }, section ".fix" |