Skip to content

Commit 04e5e72

Browse files
committed
Adding Test Cases
1 parent f5095e9 commit 04e5e72

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %clang_cc1 -emit-llvm -triple powerpc64-ibm-aix-xcoff \
2+
// RUN: %s -o - | FileCheck %s
3+
4+
#include <stdint.h>
5+
6+
// Test Atomic Memory Operation Support:
7+
// This test case takes an address and performs an atomic load at that address.
8+
// The purpose is to test the Q machine constraint and P machine constraint
9+
// argument modifier together.
10+
// These constraints on the pointer `ptr` read as: constrain (uint32_t*)ptr to
11+
// read and writeable X-Form Addressed Memory operands.
12+
static __attribute__((noinline))
13+
uint32_t atomic_load(uint32_t *ptr, uint32_t val)
14+
{
15+
// CHECK-LABEL: define{{.*}} i32 @atomic_load(ptr noundef %ptr, i32 noundef zeroext %val)
16+
// CHECK: %3 = call { i128, i32 } asm sideeffect "mr ${1:L},$3\0A\09 lwat $1,${0:P},$4\0A\09 mr $2,$1\0A", "=*Q,=&r,=r,r,n,0"(ptr elementtype(i32) %arrayidx, i32 %2, i32 0, i32 %1)
17+
unsigned __int128 tmp;
18+
uint32_t ret;
19+
__asm__ volatile ("mr %L1,%3\n"
20+
"\t lwat %1,%P0,%4\n"
21+
"\t mr %2,%1\n"
22+
: "+Q" (ptr[0]), "=&r" (tmp), "=r" (ret)
23+
: "r" (val), "n" (0x00));
24+
return ret;
25+
}
26+
27+
int main(int argc, char **argv) {
28+
return atomic_load((uint32_t*)argv[1], (uint32_t)*(argv[2]));
29+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -verify-machineinstrs < %s -mcpu=pwr8 \
3+
; RUN: -mtriple=powerpc64-ibm-aix-xcoff | FileCheck %s
4+
5+
define zeroext i32 @atomic_load(ptr %ptr, i32 zeroext range(i32 0, 256) %val) {
6+
; CHECK-LABEL: atomic_load:
7+
; CHECK: # %bb.0: # %entry
8+
; CHECK-NEXT: #APP
9+
; CHECK-NEXT: mr 6, 4
10+
; CHECK-NEXT: lwat 5, 3, 0
11+
; CHECK-NEXT: mr 3, 5
12+
; CHECK-EMPTY:
13+
; CHECK-NEXT: #NO_APP
14+
; CHECK-NEXT: clrldi 3, 3, 32
15+
; CHECK-NEXT: blr
16+
entry:
17+
%0 = load i32, ptr %ptr, align 4
18+
%1 = tail call { i128, i32 } asm sideeffect "mr ${1:L},$3\0A\09 lwat $1,${0:P},$4\0A\09 mr $2,$1\0A", "=*Q,=&r,=r,r,n,0"(ptr nonnull elementtype(i32) %ptr, i32 %val, i32 0, i32 %0)
19+
%asmresult1 = extractvalue { i128, i32 } %1, 1
20+
ret i32 %asmresult1
21+
}

0 commit comments

Comments
 (0)