[PATCH] Add implementations of __readfs{byte, word, dword, qword} to Intrin.h

Reid Kleckner rnk at google.com
Thu Jan 23 10:07:46 PST 2014


  LGTM


================
Comment at: lib/Headers/Intrin.h:779
@@ +778,3 @@
+  unsigned char __result;
+  __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));
+  return __result;
----------------
Can you add explicit size suffixes so we get better error checking here?

I think you can use movb, movw, movl, and movq.

================
Comment at: lib/Headers/Intrin.h:777
@@ +776,3 @@
+static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))
+__readfsbyte(unsigned long __addr) {
+  unsigned char __result;
----------------
I would use __offset instead of __addr.

================
Comment at: lib/Headers/Intrin.h:779
@@ +778,3 @@
+  unsigned char __result;
+  __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));
+  return __result;
----------------
Reid Kleckner wrote:
> Can you add explicit size suffixes so we get better error checking here?
> 
> I think you can use movb, movw, movl, and movq.
I spent a while fooling around with multi-alternative constraints trying to get clang to produce 'movb %fs:0, %reg' for __readfsbyte(0), but I gave up.  Our inline asm stuff isn't sophisticated enough to handle that.


http://llvm-reviews.chandlerc.com/D2606



More information about the cfe-commits mailing list