[llvm-commits] [llvm] r91973 - /llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h

Sean Callanan scallanan at apple.com
Tue Dec 22 17:55:17 PST 2009


Chris, Anton,

I tried static functions but they don't work because the compiler warns about unused functions in files that #include the header but don't call the functions.  As an alternative, I could simply move the functions into the file that uses them and declare them static thereā€¦ is that preferable?

The reason I wrote this portion of the disassembler in C is to allow projects that need a disassembler but reside (for example) in a kernel or some other source base that does not allow C++ to use the disassembler core.

Sean

On Dec 22, 2009, at 5:48 PM, Chris Lattner wrote:

> 
> On Dec 22, 2009, at 5:32 PM, Sean Callanan wrote:
> 
>> Author: spyffe
>> Date: Tue Dec 22 19:32:29 2009
>> New Revision: 91973
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=91973&view=rev
>> Log:
>> More fixes for Visual C++.  Replaced several very small
>> static inline functions with macros.
> 
> Please make these static functions.  Compilers inline static functions too.  Anton has a good point though, why is this a C file?
> 
> -Chris
> 
>> 
>> Modified:
>>   llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
>> 
>> Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h?rev=91973&r1=91972&r2=91973&view=diff
>> 
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h (original)
>> +++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h Tue Dec 22 19:32:29 2009
>> @@ -34,16 +34,16 @@
>> /*
>> * Accessor functions for various fields of an Intel instruction
>> */
>> -static inline uint8_t modFromModRM(uint8_t modRM){ return (modRM & 0xc0) >> 6; }
>> -static inline uint8_t regFromModRM(uint8_t modRM){ return (modRM & 0x38) >> 3; }
>> -static inline uint8_t rmFromModRM(uint8_t modRM) { return (modRM & 0x7);       }
>> -static inline uint8_t scaleFromSIB(uint8_t sib)  { return (sib & 0xc0) >> 6;   }
>> -static inline uint8_t indexFromSIB(uint8_t sib)  { return (sib & 0x38) >> 3;   }
>> -static inline uint8_t baseFromSIB(uint8_t sib)   { return (sib & 0x7);         }
>> -static inline uint8_t wFromREX(uint8_t rex)      { return (rex & 0x8) >> 3;    }
>> -static inline uint8_t rFromREX(uint8_t rex)      { return (rex & 0x4) >> 2;    }
>> -static inline uint8_t xFromREX(uint8_t rex)      { return (rex & 0x2) >> 1;    }
>> -static inline uint8_t bFromREX(uint8_t rex)      { return (rex & 0x1);         }
>> +#define modFromModRM(modRM)  ((modRM & 0xc0) >> 6)
>> +#define regFromModRM(modRM)  ((modRM & 0x38) >> 3)
>> +#define rmFromModRM(modRM)   (modRM & 0x7)
>> +#define scaleFromSIB(sib)    ((sib & 0xc0) >> 6)
>> +#define indexFromSIB(sib)    ((sib & 0x38) >> 3)
>> +#define baseFromSIB(sib)     (sib & 0x7)
>> +#define wFromREX(rex)        ((rex & 0x8) >> 3)
>> +#define rFromREX(rex)        ((rex & 0x4) >> 2)
>> +#define xFromREX(rex)        ((rex & 0x2) >> 1)
>> +#define bFromREX(rex)        (rex & 0x1)
>> 
>> /*
>> * These enums represent Intel registers for use by the decoder.
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 





More information about the llvm-commits mailing list