Eliminate the uchar typedef, use unsigned char explicitly

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6283 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2003-05-22 18:08:30 +00:00
parent 8a879a16cf
commit 12e6465d89
4 changed files with 55 additions and 37 deletions

View File

@ -13,8 +13,8 @@
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include <algorithm> #include <algorithm>
const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf, const Type *BytecodeParser::parseTypeConstant(const unsigned char *&Buf,
const uchar *EndBuf) { const unsigned char *EndBuf) {
unsigned PrimType; unsigned PrimType;
if (read_vbr(Buf, EndBuf, PrimType)) return 0; if (read_vbr(Buf, EndBuf, PrimType)) return 0;
@ -131,7 +131,8 @@ void BytecodeParser::refineAbstractType(const DerivedType *OldType,
// with a new resolved concrete type. // with a new resolved concrete type.
// //
void debug_type_tables(); void debug_type_tables();
bool BytecodeParser::parseTypeConstants(const uchar *&Buf, const uchar *EndBuf, bool BytecodeParser::parseTypeConstants(const unsigned char *&Buf,
const unsigned char *EndBuf,
TypeValuesListTy &Tab, TypeValuesListTy &Tab,
unsigned NumEntries) { unsigned NumEntries) {
assert(Tab.size() == 0 && "should not have read type constants in before!"); assert(Tab.size() == 0 && "should not have read type constants in before!");
@ -173,7 +174,8 @@ bool BytecodeParser::parseTypeConstants(const uchar *&Buf, const uchar *EndBuf,
} }
bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf, bool BytecodeParser::parseConstantValue(const unsigned char *&Buf,
const unsigned char *EndBuf,
const Type *Ty, Constant *&V) { const Type *Ty, Constant *&V) {
// We must check for a ConstantExpr before switching by type because // We must check for a ConstantExpr before switching by type because
@ -379,12 +381,14 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
return false; return false;
} }
bool BytecodeParser::ParseGlobalTypes(const uchar *&Buf, const uchar *EndBuf) { bool BytecodeParser::ParseGlobalTypes(const unsigned char *&Buf,
const unsigned char *EndBuf) {
ValueTable T; ValueTable T;
return ParseConstantPool(Buf, EndBuf, T, ModuleTypeValues); return ParseConstantPool(Buf, EndBuf, T, ModuleTypeValues);
} }
bool BytecodeParser::ParseConstantPool(const uchar *&Buf, const uchar *EndBuf, bool BytecodeParser::ParseConstantPool(const unsigned char *&Buf,
const unsigned char *EndBuf,
ValueTable &Tab, ValueTable &Tab,
TypeValuesListTy &TypeTab) { TypeValuesListTy &TypeTab) {
while (Buf < EndBuf) { while (Buf < EndBuf) {

View File

@ -17,7 +17,8 @@
#include "llvm/iPHINode.h" #include "llvm/iPHINode.h"
#include "llvm/iOther.h" #include "llvm/iOther.h"
bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf, bool BytecodeParser::ParseRawInst(const unsigned char *&Buf,
const unsigned char *EndBuf,
RawInst &Result) { RawInst &Result) {
unsigned Op, Typ; unsigned Op, Typ;
if (read(Buf, EndBuf, Op)) return true; if (read(Buf, EndBuf, Op)) return true;
@ -113,7 +114,8 @@ bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf,
} }
bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
const unsigned char *EndBuf,
Instruction *&Res, Instruction *&Res,
BasicBlock *BB /*HACK*/) { BasicBlock *BB /*HACK*/) {
RawInst Raw; RawInst Raw;

View File

@ -215,7 +215,8 @@ bool BytecodeParser::postResolveValues(ValueTable &ValTab) {
return Error; return Error;
} }
bool BytecodeParser::ParseBasicBlock(const uchar *&Buf, const uchar *EndBuf, bool BytecodeParser::ParseBasicBlock(const unsigned char *&Buf,
const unsigned char *EndBuf,
BasicBlock *&BB) { BasicBlock *&BB) {
BB = new BasicBlock(); BB = new BasicBlock();
@ -237,7 +238,8 @@ bool BytecodeParser::ParseBasicBlock(const uchar *&Buf, const uchar *EndBuf,
return false; return false;
} }
bool BytecodeParser::ParseSymbolTable(const uchar *&Buf, const uchar *EndBuf, bool BytecodeParser::ParseSymbolTable(const unsigned char *&Buf,
const unsigned char *EndBuf,
SymbolTable *ST) { SymbolTable *ST) {
while (Buf < EndBuf) { while (Buf < EndBuf) {
// Symtab block header: [num entries][type id number] // Symtab block header: [num entries][type id number]
@ -294,7 +296,8 @@ void BytecodeParser::ResolveReferencesToValue(Value *NewV, unsigned Slot) {
} }
bool BytecodeParser::ParseFunction(const uchar *&Buf, const uchar *EndBuf) { bool BytecodeParser::ParseFunction(const unsigned char *&Buf,
const unsigned char *EndBuf) {
// Clear out the local values table... // Clear out the local values table...
if (FunctionSignatureList.empty()) { if (FunctionSignatureList.empty()) {
Error = "Function found, but FunctionSignatureList empty!"; Error = "Function found, but FunctionSignatureList empty!";
@ -390,7 +393,8 @@ bool BytecodeParser::ParseFunction(const uchar *&Buf, const uchar *EndBuf) {
return false; return false;
} }
bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End){ bool BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf,
const unsigned char *End){
if (!FunctionSignatureList.empty()) { if (!FunctionSignatureList.empty()) {
Error = "Two ModuleGlobalInfo packets found!"; Error = "Two ModuleGlobalInfo packets found!";
return true; // Two ModuleGlobal blocks? return true; // Two ModuleGlobal blocks?
@ -488,7 +492,8 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End){
return false; return false;
} }
bool BytecodeParser::ParseVersionInfo(const uchar *&Buf, const uchar *EndBuf) { bool BytecodeParser::ParseVersionInfo(const unsigned char *&Buf,
const unsigned char *EndBuf) {
unsigned Version; unsigned Version;
if (read_vbr(Buf, EndBuf, Version)) return true; if (read_vbr(Buf, EndBuf, Version)) return true;
@ -538,7 +543,8 @@ bool BytecodeParser::ParseVersionInfo(const uchar *&Buf, const uchar *EndBuf) {
return false; return false;
} }
bool BytecodeParser::ParseModule(const uchar *Buf, const uchar *EndBuf) { bool BytecodeParser::ParseModule(const unsigned char *Buf,
const unsigned char *EndBuf) {
unsigned Type, Size; unsigned Type, Size;
if (readBlock(Buf, EndBuf, Type, Size)) return true; if (readBlock(Buf, EndBuf, Type, Size)) return true;
if (Type != BytecodeFormat::Module || Buf+Size != EndBuf) { if (Type != BytecodeFormat::Module || Buf+Size != EndBuf) {
@ -625,7 +631,8 @@ static inline Module *Error(std::string *ErrorStr, const char *Message) {
return 0; return 0;
} }
Module *BytecodeParser::ParseBytecode(const uchar *Buf, const uchar *EndBuf, Module *BytecodeParser::ParseBytecode(const unsigned char *Buf,
const unsigned char *EndBuf,
const std::string &ModuleID) { const std::string &ModuleID) {
unsigned Sig; unsigned Sig;
// Read and check signature... // Read and check signature...
@ -703,7 +710,7 @@ Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) {
munmap((char*)Buffer, Length); munmap((char*)Buffer, Length);
} else { // Read from stdin } else { // Read from stdin
int BlockSize; int BlockSize;
uchar Buffer[4096*4]; unsigned char Buffer[4096*4];
std::vector<unsigned char> FileData; std::vector<unsigned char> FileData;
// Read in all of the data from stdin, we cannot mmap stdin... // Read in all of the data from stdin, we cannot mmap stdin...
@ -719,9 +726,10 @@ Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) {
#define ALIGN_PTRS 0 #define ALIGN_PTRS 0
#if ALIGN_PTRS #if ALIGN_PTRS
uchar *Buf = (uchar*)mmap(0, FileData.size(), PROT_READ|PROT_WRITE, unsigned char *Buf =
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); (unsigned char*)mmap(0, FileData.size(), PROT_READ|PROT_WRITE,
assert((Buf != (uchar*)-1) && "mmap returned error!"); MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
assert((Buf != (unsigned char*)-1) && "mmap returned error!");
memcpy(Buf, &FileData[0], FileData.size()); memcpy(Buf, &FileData[0], FileData.size());
#else #else
unsigned char *Buf = &FileData[0]; unsigned char *Buf = &FileData[0];

View File

@ -24,8 +24,6 @@
#define BCR_TRACE(n, X) #define BCR_TRACE(n, X)
#endif #endif
typedef unsigned char uchar;
struct RawInst { // The raw fields out of the bytecode stream... struct RawInst { // The raw fields out of the bytecode stream...
unsigned NumOperands; unsigned NumOperands;
unsigned Opcode; unsigned Opcode;
@ -52,7 +50,7 @@ public:
freeTable(ModuleValues); freeTable(ModuleValues);
} }
Module *ParseBytecode(const uchar *Buf, const uchar *EndBuf, Module *ParseBytecode(const unsigned char *Buf, const unsigned char *EndBuf,
const std::string &ModuleID); const std::string &ModuleID);
std::string getError() const { return Error; } std::string getError() const { return Error; }
@ -128,24 +126,29 @@ private:
} }
} }
bool ParseModule (const uchar * Buf, const uchar *End); bool ParseModule (const unsigned char * Buf, const unsigned char *End);
bool ParseVersionInfo (const uchar *&Buf, const uchar *End); bool ParseVersionInfo (const unsigned char *&Buf, const unsigned char *End);
bool ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End); bool ParseModuleGlobalInfo(const unsigned char *&Buf, const unsigned char *E);
bool ParseSymbolTable (const uchar *&Buf, const uchar *End, SymbolTable *); bool ParseSymbolTable (const unsigned char *&Buf, const unsigned char *End,
bool ParseFunction (const uchar *&Buf, const uchar *End); SymbolTable *);
bool ParseBasicBlock (const uchar *&Buf, const uchar *End, BasicBlock *&); bool ParseFunction (const unsigned char *&Buf, const unsigned char *End);
bool ParseInstruction (const uchar *&Buf, const uchar *End, Instruction *&, bool ParseBasicBlock (const unsigned char *&Buf, const unsigned char *End,
BasicBlock *BB /*HACK*/); BasicBlock *&);
bool ParseRawInst (const uchar *&Buf, const uchar *End, RawInst &); bool ParseInstruction (const unsigned char *&Buf, const unsigned char *End,
Instruction *&, BasicBlock *BB /*HACK*/);
bool ParseRawInst (const unsigned char *&Buf, const unsigned char *End,
RawInst &);
bool ParseGlobalTypes(const uchar *&Buf, const uchar *EndBuf); bool ParseGlobalTypes(const unsigned char *&Buf, const unsigned char *EndBuf);
bool ParseConstantPool(const uchar *&Buf, const uchar *EndBuf, bool ParseConstantPool(const unsigned char *&Buf, const unsigned char *EndBuf,
ValueTable &Tab, TypeValuesListTy &TypeTab); ValueTable &Tab, TypeValuesListTy &TypeTab);
bool parseConstantValue(const uchar *&Buf, const uchar *End, bool parseConstantValue(const unsigned char *&Buf, const unsigned char *End,
const Type *Ty, Constant *&V); const Type *Ty, Constant *&V);
bool parseTypeConstants(const uchar *&Buf, const uchar *EndBuf, bool parseTypeConstants(const unsigned char *&Buf,
const unsigned char *EndBuf,
TypeValuesListTy &Tab, unsigned NumEntries); TypeValuesListTy &Tab, unsigned NumEntries);
const Type *parseTypeConstant(const uchar *&Buf, const uchar *EndBuf); const Type *parseTypeConstant(const unsigned char *&Buf,
const unsigned char *EndBuf);
Value *getValue(const Type *Ty, unsigned num, bool Create = true); Value *getValue(const Type *Ty, unsigned num, bool Create = true);
const Type *getType(unsigned ID); const Type *getType(unsigned ID);
@ -212,7 +215,8 @@ static inline unsigned getValueIDNumberFromPlaceHolder(Value *Val) {
} }
} }
static inline bool readBlock(const uchar *&Buf, const uchar *EndBuf, static inline bool readBlock(const unsigned char *&Buf,
const unsigned char *EndBuf,
unsigned &Type, unsigned &Size) { unsigned &Type, unsigned &Size) {
#if DEBUG_OUTPUT #if DEBUG_OUTPUT
bool Result = read(Buf, EndBuf, Type) || read(Buf, EndBuf, Size); bool Result = read(Buf, EndBuf, Type) || read(Buf, EndBuf, Size);