[clang] [X86] Add support for MS inp functions. (PR #93804)
Malay Sanghi via cfe-commits
cfe-commits at lists.llvm.org
Thu May 30 21:20:06 PDT 2024
================
@@ -63,6 +63,47 @@ unsigned __int64 test__emulu(unsigned int a, unsigned int b) {
// CHECK: [[RES:%[0-9]+]] = mul nuw i64 [[Y]], [[X]]
// CHECK: ret i64 [[RES]]
+
+int test_inp(unsigned short port) {
+ return _inp(port);
+}
+// CHECK-LABEL: i32 @test_inp(i16 noundef
+// CHECK-SAME: [[PORT:%.*]])
+// CHECK: [[TMP0:%.*]] = tail call i32 asm sideeffect "inb ${1:b}, ${0:b}", "={ax},N{dx},~{dirflag},~{fpsr},~{flags}"(i16 [[PORT]])
+// CHECK-NEXT: ret i32 [[TMP0]]
+
+unsigned short test_inpw(unsigned short port) {
+ return _inpw(port);
+}
+// CHECK-LABEL: i16 @test_inpw(i16 noundef
+// CHECK-SAME: [[PORT:%.*]])
+// CHECK: [[TMP0:%.*]] = tail call i16 asm sideeffect "inw ${1:w}, ${0:b}", "={ax},N{dx},~{dirflag},~{fpsr},~{flags}"(i16 [[PORT]])
+// CHECK-NEXT: ret i16 [[TMP0]]
+
+unsigned long test_inpd(unsigned short port) {
+ return _inpd(port);
+}
+// CHECK-LABEL: i32 @test_inpd(i16 noundef
+// CHECK-SAME: [[PORT:%.*]])
+// CHECK: [[TMP0:%.*]] = tail call i32 asm sideeffect "inl ${1:k}, ${0:b}", "={ax},N{dx},~{dirflag},~{fpsr},~{flags}"(i16 [[PORT]])
----------------
MalaySanghi wrote:
In llvm-IR this remain ax.
There were other issues which I fixed. I had only tested the outp end-end and modelled this after the outp intrinsic. I've tested this end-end now.
```
_ind(port)
```
becomes
```
%0 = tail call i32 asm sideeffect "inl ${1:w}, ${0:k}", "={ax},N{dx},~{dirflag},~{fpsr},~{flags}"(i16 %port) #3, !srcloc !6
```
and eventually
```
inl %dx, %eax
```
https://github.com/llvm/llvm-project/pull/93804
More information about the cfe-commits
mailing list