File: asm-inout.c

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,634,820 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (57 lines) | stat: -rw-r--r-- 1,913 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
// PR3800
int *foo(void);

// CHECK: @test1
void test1(void) {
  // CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call ptr @foo()
  // CHECK: call void asm "foobar", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) [[REGCALLRESULT]], ptr elementtype(i32) [[REGCALLRESULT]])
  asm ("foobar" : "+m"(*foo()));
}

// CHECK: @test2
void test2(void) {
  // CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call ptr @foo()
  // CHECK: load i32, ptr [[REGCALLRESULT]]
  // CHECK: call i32 asm
  // CHECK: store i32 {{%[a-zA-Z0-9\.]+}}, ptr [[REGCALLRESULT]]
  asm ("foobar" : "+r"(*foo()));
}

// PR7338
// CHECK: @test3
void test3(int *vout, int vin)
{
  // CHECK: call void asm "opr $0,$1", "=*r|m|r,r|m|r,~{edi},~{dirflag},~{fpsr},~{flags}"
  asm ("opr %[vout],%[vin]"
       : [vout] "=r,=m,=r" (*vout)
       : [vin] "r,m,r" (vin)
       : "edi");
}

// PR8959 - This should implicitly truncate the immediate to a byte.
// CHECK: @test4
int test4(volatile int *addr) {
  unsigned char oldval;
  // CHECK: call i8 asm "frob $0", "=r,0{{.*}}"(i8 -1)
  __asm__ ("frob %0" : "=r"(oldval) : "0"(0xff));
  return (int)oldval;
}

// <rdar://problem/10919182> - This should have both inputs be of type x86_mmx.
// CHECK: @test5
typedef long long __m64 __attribute__((__vector_size__(8)));
__m64 test5(__m64 __A, __m64 __B) {
  // CHECK: call x86_mmx asm "pmulhuw $1, $0\0A\09", "=y,y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %{{.*}}, x86_mmx %{{.*}})
  asm ("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B));
  return __A;
}

// CHECK: @test6
int test6(void) {
  typedef unsigned char __attribute__((vector_size(8))) _m64u8;
  _m64u8 __attribute__((aligned(16))) Mu8_0, __attribute__((aligned(16))) Mu8_1;
  // CHECK: call x86_mmx asm "nop", "=y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %1)
  asm ("nop" : "=y"(Mu8_1 ) : "0"(Mu8_0 ));
  return 0;
}