File: riscv32-zbp.c

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (179 lines) | stat: -rw-r--r-- 7,221 bytes parent folder | download
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// RUN: %clang_cc1 -no-opaque-pointers -triple riscv32 -target-feature +experimental-zbp -emit-llvm %s -o - \
// RUN:     | FileCheck %s  -check-prefix=RV32ZBP

// RV32ZBP-LABEL: @grev(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[RS2_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP2:%.*]] = call i32 @llvm.riscv.grev.i32(i32 [[TMP0]], i32 [[TMP1]])
// RV32ZBP-NEXT:    ret i32 [[TMP2]]
//
long grev(long rs1, long rs2)
{
  return __builtin_riscv_grev_32(rs1, rs2);
}

// RV32ZBP-LABEL: @grevi(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[I:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 13, i32* [[I]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = call i32 @llvm.riscv.grev.i32(i32 [[TMP0]], i32 13)
// RV32ZBP-NEXT:    ret i32 [[TMP1]]
//
long grevi(long rs1)
{
  const int i = 13;
  return __builtin_riscv_grev_32(rs1, i);
}

// RV32ZBP-LABEL: @gorc(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[RS2_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP2:%.*]] = call i32 @llvm.riscv.gorc.i32(i32 [[TMP0]], i32 [[TMP1]])
// RV32ZBP-NEXT:    ret i32 [[TMP2]]
//
long gorc(long rs1, long rs2)
{
  return __builtin_riscv_gorc_32(rs1, rs2);
}

// RV32ZBP-LABEL: @gorci(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[I:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 13, i32* [[I]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = call i32 @llvm.riscv.gorc.i32(i32 [[TMP0]], i32 13)
// RV32ZBP-NEXT:    ret i32 [[TMP1]]
//
long gorci(long rs1)
{
  const int i = 13;
  return __builtin_riscv_gorc_32(rs1, i);
}

// RV32ZBP-LABEL: @shfl(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[RS2_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP2:%.*]] = call i32 @llvm.riscv.shfl.i32(i32 [[TMP0]], i32 [[TMP1]])
// RV32ZBP-NEXT:    ret i32 [[TMP2]]
//
long shfl(long rs1, long rs2)
{
  return __builtin_riscv_shfl_32(rs1, rs2);
}

// RV32ZBP-LABEL: @shfli(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[I:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 13, i32* [[I]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = call i32 @llvm.riscv.shfl.i32(i32 [[TMP0]], i32 13)
// RV32ZBP-NEXT:    ret i32 [[TMP1]]
//
long shfli(long rs1)
{
  const int i = 13;
  return __builtin_riscv_shfl_32(rs1, i);
}

// RV32ZBP-LABEL: @unshfl(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[RS2_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP2:%.*]] = call i32 @llvm.riscv.unshfl.i32(i32 [[TMP0]], i32 [[TMP1]])
// RV32ZBP-NEXT:    ret i32 [[TMP2]]
//
long unshfl(long rs1, long rs2)
{
  return __builtin_riscv_unshfl_32(rs1, rs2);
}

// RV32ZBP-LABEL: @unshfli(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[I:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 13, i32* [[I]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = call i32 @llvm.riscv.unshfl.i32(i32 [[TMP0]], i32 13)
// RV32ZBP-NEXT:    ret i32 [[TMP1]]
//
long unshfli(long rs1)
{
  const int i = 13;
  return __builtin_riscv_unshfl_32(rs1, i);
}

// RV32ZBP-LABEL: @xperm_n(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[RS2_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP2:%.*]] = call i32 @llvm.riscv.xperm.n.i32(i32 [[TMP0]], i32 [[TMP1]])
// RV32ZBP-NEXT:    ret i32 [[TMP2]]
//
long xperm_n(long rs1, long rs2)
{
  return __builtin_riscv_xperm_n(rs1, rs2);
}

// RV32ZBP-LABEL: @xperm_b(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[RS2_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP2:%.*]] = call i32 @llvm.riscv.xperm.b.i32(i32 [[TMP0]], i32 [[TMP1]])
// RV32ZBP-NEXT:    ret i32 [[TMP2]]
//
long xperm_b(long rs1, long rs2)
{
  return __builtin_riscv_xperm_b(rs1, rs2);
}

// RV32ZBP-LABEL: @xperm_h(
// RV32ZBP-NEXT:  entry:
// RV32ZBP-NEXT:    [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    [[RS2_ADDR:%.*]] = alloca i32, align 4
// RV32ZBP-NEXT:    store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    store i32 [[RS2:%.*]], i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP1:%.*]] = load i32, i32* [[RS2_ADDR]], align 4
// RV32ZBP-NEXT:    [[TMP2:%.*]] = call i32 @llvm.riscv.xperm.h.i32(i32 [[TMP0]], i32 [[TMP1]])
// RV32ZBP-NEXT:    ret i32 [[TMP2]]
//
long xperm_h(long rs1, long rs2)
{
  return __builtin_riscv_xperm_h(rs1, rs2);
}