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

Hans Wennborg hans at chromium.org
Thu Jan 23 10:37:18 PST 2014



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

================
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:
> 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.
That's a good idea. Added the suffixes.


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



More information about the cfe-commits mailing list