62 lines · c
1// REQUIRES: powerpc-registered-target2// RUN: %clang_cc1 -O2 -target-cpu pwr8 -triple=powerpc-unknown-aix \3// RUN: -emit-llvm %s -o - | FileCheck %s4// RUN: %clang_cc1 -O2 -target-cpu pwr8 -triple=powerpc64-unknown-aix \5// RUN: -emit-llvm %s -o - | FileCheck %s6// RUN: %clang_cc1 -O2 -target-cpu pwr8 -triple=powerpc64le-unknown-linux-gnu \7// RUN: -emit-llvm %s -o - | FileCheck %s8// RUN: %clang_cc1 -O2 -target-cpu pwr8 -triple=powerpc64-unknown-linux-gnu \9// RUN: -emit-llvm %s -o - | FileCheck %s10// RAUN: not %clang_cc1 -O2 -target-cpu pwr7 -triple=powerpc-unknown-aix \11// RAUN: -emit-llvm %s -o - 2>&1 | FileCheck %s \12// RAUN: --check-prefix=CHECK-NON-PWR8-ERR13 14int test_lwarx(volatile int* a) {15 // CHECK-LABEL: @test_lwarx16 // CHECK: %0 = tail call i32 asm sideeffect "lwarx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i32) %a)17 return __lwarx(a);18}19 20short test_lharx(volatile short *a) {21 // CHECK-LABEL: @test_lharx22 // CHECK: %0 = tail call i16 asm sideeffect "lharx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i16) %a)23 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs24 return __lharx(a);25}26 27char test_lbarx(volatile char *a) {28 // CHECK-LABEL: @test_lbarx29 // CHECK: %0 = tail call i8 asm sideeffect "lbarx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i8) %a)30 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs31 return __lbarx(a);32}33 34int test_stwcx(volatile int* a, int val) {35 // CHECK-LABEL: @test_stwcx36 // CHECK: %0 = tail call i32 @llvm.ppc.stwcx(ptr %a, i32 %val)37 return __stwcx(a, val);38}39 40int test_sthcx(volatile short *a, short val) {41 // CHECK-LABEL: @test_sthcx42 // CHECK: %0 = sext i16 %val to i3243 // CHECK: %1 = tail call i32 @llvm.ppc.sthcx(ptr %a, i32 %0)44 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs45 return __sthcx(a, val);46}47 48// Extra test cases that previously caused error during usage.49int test_lharx_intret(volatile short *a) {50 // CHECK-LABEL: @test_lharx_intret51 // CHECK: %0 = tail call i16 asm sideeffect "lharx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i16) %a)52 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs53 return __lharx(a);54}55 56int test_lbarx_intret(volatile char *a) {57 // CHECK-LABEL: @test_lbarx_intret58 // CHECK: %0 = tail call i8 asm sideeffect "lbarx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i8) %a)59 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs60 return __lbarx(a);61}62