File: nvptx-inlineasm-ptx.c

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (40 lines) | stat: -rw-r--r-- 1,556 bytes parent folder | download | duplicates (6)
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
// RUN: %clang_cc1 -triple nvptx-unknown-unknown -O3 -S -o - %s -emit-llvm | FileCheck %s
// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -O3 -S -o - %s -emit-llvm | FileCheck %s

void constraints(void) {
  char           c;
  unsigned char  uc;
  short          s;
  unsigned short us;
  int            i;
  unsigned int   ui;
  long long      ll;
  unsigned long long ull;
  float          f;
  double         d;

  // CHECK: i8 asm sideeffect "mov.b8 $0, $1;", "=c,c"
  asm volatile ("mov.b8 %0, %1;" : "=c"(c) : "c"(c));
  // CHECK: i8 asm sideeffect "mov.b8 $0, $1;", "=c,c"
  asm volatile ("mov.b8 %0, %1;" : "=c"(uc) : "c"(uc));

  // CHECK: i16 asm sideeffect "mov.b16 $0, $1;", "=h,h"
  asm volatile ("mov.b16 %0, %1;" : "=h"(s) : "h"(s));
  // CHECK: i16 asm sideeffect "mov.b16 $0, $1;", "=h,h"
  asm volatile ("mov.b16 %0, %1;" : "=h"(us) : "h"(us));

  // CHECK: i32 asm sideeffect "mov.b32 $0, $1;", "=r,r"
  asm volatile ("mov.b32 %0, %1;" : "=r"(i) : "r"(i));
  // CHECK: i32 asm sideeffect "mov.b32 $0, $1;", "=r,r"
  asm volatile ("mov.b32 %0, %1;" : "=r"(ui) : "r"(ui));

  // CHECK: i64 asm sideeffect "mov.b64 $0, $1;", "=l,l"
  asm volatile ("mov.b64 %0, %1;" : "=l"(ll) : "l"(ll));
  // CHECK: i64 asm sideeffect "mov.b64 $0, $1;", "=l,l"
  asm volatile ("mov.b64 %0, %1;" : "=l"(ull) : "l"(ull));

  // CHECK: float asm sideeffect "mov.b32 $0, $1;", "=f,f"
  asm volatile ("mov.b32 %0, %1;" : "=f"(f) : "f"(f));
  // CHECK: double asm sideeffect "mov.b64 $0, $1;", "=d,d"
  asm volatile ("mov.b64 %0, %1;" : "=d"(d) : "d"(d));
}