[clang] [X86] Add support for MS inp functions. (PR #93804)

Phoebe Wang via cfe-commits cfe-commits at lists.llvm.org
Thu May 30 22:05:30 PDT 2024


================
@@ -329,6 +329,28 @@ static __inline__ void __DEFAULT_FN_ATTRS __stosq(unsigned __int64 *__dst,
 static __inline__ void __DEFAULT_FN_ATTRS __halt(void) {
   __asm__ volatile("hlt");
 }
+
+static inline int _inp(unsigned short port) {
+  int ret;
+  __asm__ volatile("inb %w1, %b0" : "=a"(ret) : "Nd"(port));
+  return ret;
+}
+
+static inline unsigned short _inpw(unsigned short port) {
+  unsigned short ret;
+  __asm__ volatile("inw %w1, %w0" : "=a"(ret) : "Nd"(port));
+  return ret;
+}
+
+static inline unsigned long _inpd(unsigned short port) {
+  unsigned long ret;
+  __asm__ volatile("inl %w1, %k0" : "=a"(ret) : "Nd"(port));
+  return ret;
+}
+
+#define inp(port) _inp((port))
+#define inpw(port) _inpw((port))
----------------
phoebewang wrote:

>From MSVC doc:

> The inp and inpw names are older, deprecated names for the _inp and _inpw functions.

Maybe we don't need to provide them now.

https://github.com/llvm/llvm-project/pull/93804


More information about the cfe-commits mailing list