brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.7 KiB · 48d0ea4 Raw
304 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s | FileCheck %s --check-prefixes=ALL,CHECK3; RUN: llc -O0 < %s | FileCheck %s --check-prefixes=ALL,CHECK-O04; RUN: llc --fast-isel < %s | FileCheck %s --check-prefixes=ALL,CHECK5; RUN: llc --global-isel --global-isel-abort=2 < %s | FileCheck %s --check-prefixes=ALL,CHECK6 7; Source to regenerate:8; struct Foo {9;   int * __ptr32 p32;10;   int * __ptr64 p64;11;   __attribute__((address_space(9))) int *p_other;12; };13; void use_foo(Foo *f);14; void test_sign_ext(Foo *f, int * __ptr32 __sptr i) {15;   f->p64 = i;16;   use_foo(f);17; }18; void test_zero_ext(Foo *f, int * __ptr32 __uptr i) {19;   f->p64 = i;20;   use_foo(f);21; }22; void test_trunc(Foo *f, int * __ptr64 i) {23;   f->p32 = i;24;   use_foo(f);25; }26; void test_noop1(Foo *f, int * __ptr32 i) {27;   f->p32 = i;28;   use_foo(f);29; }30; void test_noop2(Foo *f, int * __ptr64 i) {31;   f->p64 = i;32;   use_foo(f);33; }34; void test_null_arg(Foo *f, int * __ptr32 i) {35;   test_noop1(f, 0);36; }37; void test_unrecognized(Foo *f, __attribute__((address_space(14))) int *i) {38;   f->p32 = (int * __ptr32)i;39;   use_foo(f);40; }41;42; $ clang -cc1 -triple x86_64-windows-msvc -fms-extensions -O2 -S t.cpp43 44target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"45target triple = "x86_64-unknown-windows-msvc"46 47%struct.Foo = type { ptr addrspace(270), ptr, ptr addrspace(9) }48declare dso_local void @use_foo(ptr)49 50define dso_local void @test_sign_ext(ptr %f, ptr addrspace(270) %i) {51; ALL-LABEL: test_sign_ext:52; ALL:       # %bb.0: # %entry53; ALL-NEXT:    movslq %edx, %rax54; ALL-NEXT:    movq %rax, 8(%rcx)55; ALL-NEXT:    jmp use_foo # TAILCALL56entry:57  %0 = addrspacecast ptr addrspace(270) %i to ptr58  %p64 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 159  store ptr %0, ptr %p64, align 860  tail call void @use_foo(ptr %f)61  ret void62}63 64define dso_local void @test_zero_ext(ptr %f, ptr addrspace(271) %i) {65; CHECK-LABEL: test_zero_ext:66; CHECK:       # %bb.0: # %entry67; CHECK-NEXT:    movl %edx, %eax68; CHECK-NEXT:    movq %rax, 8(%rcx)69; CHECK-NEXT:    jmp use_foo # TAILCALL70;71; CHECK-O0-LABEL: test_zero_ext:72; CHECK-O0:       # %bb.0: # %entry73; CHECK-O0-NEXT:    movl %edx, %eax74; CHECK-O0-NEXT:    # kill: def $rax killed $eax75; CHECK-O0-NEXT:    movq %rax, 8(%rcx)76; CHECK-O0-NEXT:    jmp use_foo # TAILCALL77entry:78  %0 = addrspacecast ptr addrspace(271) %i to ptr79  %p64 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 180  store ptr %0, ptr %p64, align 881  tail call void @use_foo(ptr %f)82  ret void83}84 85define dso_local void @test_trunc(ptr %f, ptr %i) {86; CHECK-LABEL: test_trunc:87; CHECK:       # %bb.0: # %entry88; CHECK-NEXT:    movl %edx, (%rcx)89; CHECK-NEXT:    jmp use_foo # TAILCALL90;91; CHECK-O0-LABEL: test_trunc:92; CHECK-O0:       # %bb.0: # %entry93; CHECK-O0-NEXT:    movl %edx, %eax94; CHECK-O0-NEXT:    movl %eax, (%rcx)95; CHECK-O0-NEXT:    jmp use_foo # TAILCALL96entry:97  %0 = addrspacecast ptr %i to ptr addrspace(270)98  store ptr addrspace(270) %0, ptr %f, align 899  tail call void @use_foo(ptr %f)100  ret void101}102 103define dso_local void @test_noop1(ptr %f, ptr addrspace(270) %i) {104; ALL-LABEL: test_noop1:105; ALL:       # %bb.0: # %entry106; ALL-NEXT:    movl %edx, (%rcx)107; ALL-NEXT:    jmp use_foo # TAILCALL108entry:109  store ptr addrspace(270) %i, ptr %f, align 8110  tail call void @use_foo(ptr %f)111  ret void112}113 114define dso_local void @test_noop2(ptr %f, ptr %i) {115; ALL-LABEL: test_noop2:116; ALL:       # %bb.0: # %entry117; ALL-NEXT:    movq %rdx, 8(%rcx)118; ALL-NEXT:    jmp use_foo # TAILCALL119entry:120  %p64 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 1121  store ptr %i, ptr %p64, align 8122  tail call void @use_foo(ptr %f)123  ret void124}125 126; Test that null can be passed as a 32-bit pointer.127define dso_local void @test_null_arg(ptr %f) {128; ALL-LABEL: test_null_arg:129; ALL:       # %bb.0: # %entry130; ALL-NEXT:    subq $40, %rsp131; ALL-NEXT:    .seh_stackalloc 40132; ALL-NEXT:    .seh_endprologue133; ALL-NEXT:    xorl %edx, %edx134; ALL-NEXT:    callq test_noop1135; ALL-NEXT:    nop136; ALL-NEXT:    .seh_startepilogue137; ALL-NEXT:    addq $40, %rsp138; ALL-NEXT:    .seh_endepilogue139; ALL-NEXT:    retq140; ALL-NEXT:    .seh_endproc141entry:142  call void @test_noop1(ptr %f, ptr addrspace(270) null)143  ret void144}145 146; Test casts between unrecognized address spaces.147define void @test_unrecognized(ptr %f, ptr addrspace(14) %i) {148; CHECK-LABEL: test_unrecognized:149; CHECK:       # %bb.0: # %entry150; CHECK-NEXT:    movl %edx, (%rcx)151; CHECK-NEXT:    jmp use_foo # TAILCALL152;153; CHECK-O0-LABEL: test_unrecognized:154; CHECK-O0:       # %bb.0: # %entry155; CHECK-O0-NEXT:    movl %edx, %eax156; CHECK-O0-NEXT:    movl %eax, (%rcx)157; CHECK-O0-NEXT:    jmp use_foo # TAILCALL158entry:159  %0 = addrspacecast ptr addrspace(14) %i to ptr addrspace(270)160  store ptr addrspace(270) %0, ptr %f, align 8161  tail call void @use_foo(ptr %f)162  ret void163}164 165define void @test_unrecognized2(ptr %f, ptr addrspace(271) %i) {166; CHECK-LABEL: test_unrecognized2:167; CHECK:       # %bb.0: # %entry168; CHECK-NEXT:    movl %edx, %eax169; CHECK-NEXT:    movq %rax, 16(%rcx)170; CHECK-NEXT:    jmp use_foo # TAILCALL171;172; CHECK-O0-LABEL: test_unrecognized2:173; CHECK-O0:       # %bb.0: # %entry174; CHECK-O0-NEXT:    movl %edx, %eax175; CHECK-O0-NEXT:    # kill: def $rax killed $eax176; CHECK-O0-NEXT:    movq %rax, 16(%rcx)177; CHECK-O0-NEXT:    jmp use_foo # TAILCALL178entry:179  %0 = addrspacecast ptr addrspace(271) %i to ptr addrspace(9)180  %p32 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 2181  store ptr addrspace(9) %0, ptr %p32, align 8182  tail call void @use_foo(ptr %f)183  ret void184}185 186define i32 @test_load_sptr32(ptr addrspace(270) %i) {187; ALL-LABEL: test_load_sptr32:188; ALL:       # %bb.0: # %entry189; ALL-NEXT:    movslq %ecx, %rax190; ALL-NEXT:    movl (%rax), %eax191; ALL-NEXT:    retq192entry:193  %0 = load i32, ptr addrspace(270) %i, align 4194  ret i32 %0195}196 197define i32 @test_load_uptr32(ptr addrspace(271) %i) {198; CHECK-LABEL: test_load_uptr32:199; CHECK:       # %bb.0: # %entry200; CHECK-NEXT:    movl %ecx, %eax201; CHECK-NEXT:    movl (%rax), %eax202; CHECK-NEXT:    retq203;204; CHECK-O0-LABEL: test_load_uptr32:205; CHECK-O0:       # %bb.0: # %entry206; CHECK-O0-NEXT:    movl %ecx, %eax207; CHECK-O0-NEXT:    # kill: def $rax killed $eax208; CHECK-O0-NEXT:    movl (%rax), %eax209; CHECK-O0-NEXT:    retq210entry:211  %0 = load i32, ptr addrspace(271) %i, align 4212  ret i32 %0213}214 215define i32 @test_load_ptr64(ptr addrspace(272) %i) {216; ALL-LABEL: test_load_ptr64:217; ALL:       # %bb.0: # %entry218; ALL-NEXT:    movl (%rcx), %eax219; ALL-NEXT:    retq220entry:221  %0 = load i32, ptr addrspace(272) %i, align 8222  ret i32 %0223}224 225define void @test_store_sptr32(ptr addrspace(270) %s, i32 %i) {226; ALL-LABEL: test_store_sptr32:227; ALL:       # %bb.0: # %entry228; ALL-NEXT:    movslq %ecx, %rax229; ALL-NEXT:    movl %edx, (%rax)230; ALL-NEXT:    retq231entry:232  store i32 %i, ptr addrspace(270) %s, align 4233  ret void234}235 236define void @test_store_uptr32(ptr addrspace(271) %s, i32 %i) {237; CHECK-LABEL: test_store_uptr32:238; CHECK:       # %bb.0: # %entry239; CHECK-NEXT:    movl %ecx, %eax240; CHECK-NEXT:    movl %edx, (%rax)241; CHECK-NEXT:    retq242;243; CHECK-O0-LABEL: test_store_uptr32:244; CHECK-O0:       # %bb.0: # %entry245; CHECK-O0-NEXT:    movl %ecx, %eax246; CHECK-O0-NEXT:    # kill: def $rax killed $eax247; CHECK-O0-NEXT:    movl %edx, (%rax)248; CHECK-O0-NEXT:    retq249entry:250  store i32 %i, ptr addrspace(271) %s, align 4251  ret void252}253 254define void @test_store_ptr64(ptr addrspace(272) %s, i32 %i) {255; ALL-LABEL: test_store_ptr64:256; ALL:       # %bb.0: # %entry257; ALL-NEXT:    movl %edx, (%rcx)258; ALL-NEXT:    retq259entry:260  store i32 %i, ptr addrspace(272) %s, align 8261  ret void262}263 264define i64 @test_load_sptr32_zext_i64(ptr addrspace(270) %i) {265; CHECK-LABEL: test_load_sptr32_zext_i64:266; CHECK:       # %bb.0: # %entry267; CHECK-NEXT:    movslq %ecx, %rax268; CHECK-NEXT:    movl (%rax), %eax269; CHECK-NEXT:    retq270;271; CHECK-O0-LABEL: test_load_sptr32_zext_i64:272; CHECK-O0:       # %bb.0: # %entry273; CHECK-O0-NEXT:    movslq %ecx, %rax274; CHECK-O0-NEXT:    movl (%rax), %eax275; CHECK-O0-NEXT:    movl %eax, %eax276; CHECK-O0-NEXT:    # kill: def $rax killed $eax277; CHECK-O0-NEXT:    retq278entry:279  %0 = load i32, ptr addrspace(270) %i, align 4280  %1 = zext i32 %0 to i64281  ret i64 %1282}283 284define void @test_store_sptr32_trunc_i1(ptr addrspace(270) %s, i32 %i) {285; CHECK-LABEL: test_store_sptr32_trunc_i1:286; CHECK:       # %bb.0: # %entry287; CHECK-NEXT:    movslq %ecx, %rax288; CHECK-NEXT:    andl $1, %edx289; CHECK-NEXT:    movb %dl, (%rax)290; CHECK-NEXT:    retq291;292; CHECK-O0-LABEL: test_store_sptr32_trunc_i1:293; CHECK-O0:       # %bb.0: # %entry294; CHECK-O0-NEXT:    movslq %ecx, %rax295; CHECK-O0-NEXT:    andl $1, %edx296; CHECK-O0-NEXT:    movb %dl, %cl297; CHECK-O0-NEXT:    movb %cl, (%rax)298; CHECK-O0-NEXT:    retq299entry:300  %0 = trunc i32 %i to i1301  store i1 %0, ptr addrspace(270) %s302  ret void303}304