mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-14 04:11:30 +00:00
Move CharIsSigned from TargetInfo to LangOptions.
llvm-svn: 72928
This commit is contained in:
parent
d7bcad67d4
commit
9ffd4a9b96
@ -130,6 +130,9 @@ def warn_pch_compiler_options_mismatch : Error<
|
|||||||
def warn_pch_access_control : Error<
|
def warn_pch_access_control : Error<
|
||||||
"C++ access control was %select{disabled|enabled}0 in the PCH file but "
|
"C++ access control was %select{disabled|enabled}0 in the PCH file but "
|
||||||
"is currently %select{disabled|enabled}1">;
|
"is currently %select{disabled|enabled}1">;
|
||||||
|
def warn_pch_char_signed : Error<
|
||||||
|
"char was %select{unsigned|signed}0 in the PCH file but "
|
||||||
|
"is currently %select{unsigned|signed}1">;
|
||||||
|
|
||||||
def err_not_a_pch_file : Error<
|
def err_not_a_pch_file : Error<
|
||||||
"'%0' does not appear to be a precompiled header file">, DefaultFatal;
|
"'%0' does not appear to be a precompiled header file">, DefaultFatal;
|
||||||
|
@ -79,6 +79,7 @@ public:
|
|||||||
|
|
||||||
unsigned AccessControl : 1; // Whether C++ access control should
|
unsigned AccessControl : 1; // Whether C++ access control should
|
||||||
// be enabled.
|
// be enabled.
|
||||||
|
unsigned CharIsSigned : 1; // Whether char is a signed or unsigned type
|
||||||
private:
|
private:
|
||||||
unsigned GC : 2; // Objective-C Garbage Collection modes. We declare
|
unsigned GC : 2; // Objective-C Garbage Collection modes. We declare
|
||||||
// this enum as unsigned because MSVC insists on making enums
|
// this enum as unsigned because MSVC insists on making enums
|
||||||
@ -137,6 +138,8 @@ public:
|
|||||||
GNUInline = 0;
|
GNUInline = 0;
|
||||||
NoInline = 0;
|
NoInline = 0;
|
||||||
|
|
||||||
|
CharIsSigned = 1;
|
||||||
|
|
||||||
MainFileName = 0;
|
MainFileName = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ class TargetInfo {
|
|||||||
protected:
|
protected:
|
||||||
// Target values set by the ctor of the actual target implementation. Default
|
// Target values set by the ctor of the actual target implementation. Default
|
||||||
// values are specified by the TargetInfo constructor.
|
// values are specified by the TargetInfo constructor.
|
||||||
bool CharIsSigned;
|
|
||||||
bool TLSSupported;
|
bool TLSSupported;
|
||||||
unsigned char PointerWidth, PointerAlign;
|
unsigned char PointerWidth, PointerAlign;
|
||||||
unsigned char WCharWidth, WCharAlign;
|
unsigned char WCharWidth, WCharAlign;
|
||||||
@ -88,11 +87,6 @@ public:
|
|||||||
IntType getIntPtrType() const { return IntPtrType; }
|
IntType getIntPtrType() const { return IntPtrType; }
|
||||||
IntType getWCharType() const { return WCharType; }
|
IntType getWCharType() const { return WCharType; }
|
||||||
|
|
||||||
/// isCharSigned - Return true if 'char' is 'signed char' or false if it is
|
|
||||||
/// treated as 'unsigned char'. This is implementation defined according to
|
|
||||||
/// C99 6.2.5p15. In our implementation, this is target-specific.
|
|
||||||
bool isCharSigned() const { return CharIsSigned; }
|
|
||||||
|
|
||||||
/// getPointerWidth - Return the width of pointers on this target, for the
|
/// getPointerWidth - Return the width of pointers on this target, for the
|
||||||
/// specified address space.
|
/// specified address space.
|
||||||
uint64_t getPointerWidth(unsigned AddrSpace) const {
|
uint64_t getPointerWidth(unsigned AddrSpace) const {
|
||||||
|
@ -143,7 +143,7 @@ void ASTContext::InitBuiltinTypes() {
|
|||||||
// C99 6.2.5p2.
|
// C99 6.2.5p2.
|
||||||
InitBuiltinType(BoolTy, BuiltinType::Bool);
|
InitBuiltinType(BoolTy, BuiltinType::Bool);
|
||||||
// C99 6.2.5p3.
|
// C99 6.2.5p3.
|
||||||
if (Target.isCharSigned())
|
if (LangOpts.CharIsSigned)
|
||||||
InitBuiltinType(CharTy, BuiltinType::Char_S);
|
InitBuiltinType(CharTy, BuiltinType::Char_S);
|
||||||
else
|
else
|
||||||
InitBuiltinType(CharTy, BuiltinType::Char_U);
|
InitBuiltinType(CharTy, BuiltinType::Char_U);
|
||||||
|
@ -22,7 +22,6 @@ TargetInfo::TargetInfo(const std::string &T) : Triple(T) {
|
|||||||
// Set defaults. Defaults are set for a 32-bit RISC platform,
|
// Set defaults. Defaults are set for a 32-bit RISC platform,
|
||||||
// like PPC or SPARC.
|
// like PPC or SPARC.
|
||||||
// These should be overridden by concrete targets as needed.
|
// These should be overridden by concrete targets as needed.
|
||||||
CharIsSigned = true;
|
|
||||||
TLSSupported = true;
|
TLSSupported = true;
|
||||||
PointerWidth = PointerAlign = 32;
|
PointerWidth = PointerAlign = 32;
|
||||||
WCharWidth = WCharAlign = 32;
|
WCharWidth = WCharAlign = 32;
|
||||||
|
@ -257,9 +257,8 @@ class PPCTargetInfo : public TargetInfo {
|
|||||||
static const TargetInfo::GCCRegAlias GCCRegAliases[];
|
static const TargetInfo::GCCRegAlias GCCRegAliases[];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PPCTargetInfo(const std::string& triple) : TargetInfo(triple) {
|
PPCTargetInfo(const std::string& triple) : TargetInfo(triple) {}
|
||||||
CharIsSigned = false;
|
|
||||||
}
|
|
||||||
virtual void getTargetBuiltins(const Builtin::Info *&Records,
|
virtual void getTargetBuiltins(const Builtin::Info *&Records,
|
||||||
unsigned &NumRecords) const {
|
unsigned &NumRecords) const {
|
||||||
Records = BuiltinInfo;
|
Records = BuiltinInfo;
|
||||||
@ -299,6 +298,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
virtual void getDefaultLangOptions(LangOptions &Opts) {
|
||||||
|
TargetInfo::getDefaultLangOptions(Opts);
|
||||||
|
Opts.CharIsSigned = false;
|
||||||
|
}
|
||||||
virtual const char *getClobbers() const {
|
virtual const char *getClobbers() const {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -449,6 +452,7 @@ public:
|
|||||||
/// various language options. These may be overridden by command line
|
/// various language options. These may be overridden by command line
|
||||||
/// options.
|
/// options.
|
||||||
virtual void getDefaultLangOptions(LangOptions &Opts) {
|
virtual void getDefaultLangOptions(LangOptions &Opts) {
|
||||||
|
PPC32TargetInfo::getDefaultLangOptions(Opts);
|
||||||
GetDarwinLanguageOptions(Opts, getTargetTriple());
|
GetDarwinLanguageOptions(Opts, getTargetTriple());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -469,6 +473,7 @@ public:
|
|||||||
/// various language options. These may be overridden by command line
|
/// various language options. These may be overridden by command line
|
||||||
/// options.
|
/// options.
|
||||||
virtual void getDefaultLangOptions(LangOptions &Opts) {
|
virtual void getDefaultLangOptions(LangOptions &Opts) {
|
||||||
|
PPC64TargetInfo::getDefaultLangOptions(Opts);
|
||||||
GetDarwinLanguageOptions(Opts, getTargetTriple());
|
GetDarwinLanguageOptions(Opts, getTargetTriple());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -845,6 +850,7 @@ public:
|
|||||||
/// various language options. These may be overridden by command line
|
/// various language options. These may be overridden by command line
|
||||||
/// options.
|
/// options.
|
||||||
virtual void getDefaultLangOptions(LangOptions &Opts) {
|
virtual void getDefaultLangOptions(LangOptions &Opts) {
|
||||||
|
X86_32TargetInfo::getDefaultLangOptions(Opts);
|
||||||
GetDarwinLanguageOptions(Opts, getTargetTriple());
|
GetDarwinLanguageOptions(Opts, getTargetTriple());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -367,7 +367,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
|||||||
sprintf(MacroBuf, "__POINTER_WIDTH__=%d", (int)TI.getPointerWidth(0));
|
sprintf(MacroBuf, "__POINTER_WIDTH__=%d", (int)TI.getPointerWidth(0));
|
||||||
DefineBuiltinMacro(Buf, MacroBuf);
|
DefineBuiltinMacro(Buf, MacroBuf);
|
||||||
|
|
||||||
if (!TI.isCharSigned())
|
if (!LangOpts.CharIsSigned)
|
||||||
DefineBuiltinMacro(Buf, "__CHAR_UNSIGNED__");
|
DefineBuiltinMacro(Buf, "__CHAR_UNSIGNED__");
|
||||||
|
|
||||||
// Define fixed-sized integer types for stdint.h
|
// Define fixed-sized integer types for stdint.h
|
||||||
|
@ -1521,6 +1521,7 @@ bool PCHReader::ParseLanguageOptions(
|
|||||||
PARSE_LANGOPT_IMPORTANT(GNUInline, diag::warn_pch_gnu_inline);
|
PARSE_LANGOPT_IMPORTANT(GNUInline, diag::warn_pch_gnu_inline);
|
||||||
PARSE_LANGOPT_IMPORTANT(NoInline, diag::warn_pch_no_inline);
|
PARSE_LANGOPT_IMPORTANT(NoInline, diag::warn_pch_no_inline);
|
||||||
PARSE_LANGOPT_IMPORTANT(AccessControl, diag::warn_pch_access_control);
|
PARSE_LANGOPT_IMPORTANT(AccessControl, diag::warn_pch_access_control);
|
||||||
|
PARSE_LANGOPT_IMPORTANT(CharIsSigned, diag::warn_pch_char_signed);
|
||||||
if ((LangOpts.getGCMode() != 0) != (Record[Idx] != 0)) {
|
if ((LangOpts.getGCMode() != 0) != (Record[Idx] != 0)) {
|
||||||
Diag(diag::warn_pch_gc_mode)
|
Diag(diag::warn_pch_gc_mode)
|
||||||
<< (unsigned)Record[Idx] << LangOpts.getGCMode();
|
<< (unsigned)Record[Idx] << LangOpts.getGCMode();
|
||||||
|
@ -556,6 +556,8 @@ void PCHWriter::WriteLanguageOptions(const LangOptions &LangOpts) {
|
|||||||
Record.push_back(LangOpts.NoInline); // Should __NO_INLINE__ be defined.
|
Record.push_back(LangOpts.NoInline); // Should __NO_INLINE__ be defined.
|
||||||
Record.push_back(LangOpts.AccessControl); // Whether C++ access control should
|
Record.push_back(LangOpts.AccessControl); // Whether C++ access control should
|
||||||
// be enabled.
|
// be enabled.
|
||||||
|
Record.push_back(LangOpts.CharIsSigned); // Whether char is a signed or
|
||||||
|
// unsigned type
|
||||||
Record.push_back(LangOpts.getGCMode());
|
Record.push_back(LangOpts.getGCMode());
|
||||||
Record.push_back(LangOpts.getVisibilityMode());
|
Record.push_back(LangOpts.getVisibilityMode());
|
||||||
Record.push_back(LangOpts.InstantiationDepth);
|
Record.push_back(LangOpts.InstantiationDepth);
|
||||||
|
@ -691,7 +691,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
|
|||||||
// character constants are not sign extended in the this implementation:
|
// character constants are not sign extended in the this implementation:
|
||||||
// '\xFF\xFF' = 65536 and '\x0\xFF' = 255, which matches GCC.
|
// '\xFF\xFF' = 65536 and '\x0\xFF' = 255, which matches GCC.
|
||||||
if (!IsWide && NumCharsSoFar == 1 && (Value & 128) &&
|
if (!IsWide && NumCharsSoFar == 1 && (Value & 128) &&
|
||||||
PP.getTargetInfo().isCharSigned())
|
PP.getLangOptions().CharIsSigned)
|
||||||
Value = (signed char)Value;
|
Value = (signed char)Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
|
|||||||
// Set the value.
|
// Set the value.
|
||||||
Val = Literal.getValue();
|
Val = Literal.getValue();
|
||||||
// Set the signedness.
|
// Set the signedness.
|
||||||
Val.setIsUnsigned(!TI.isCharSigned());
|
Val.setIsUnsigned(!PP.getLangOptions().CharIsSigned);
|
||||||
|
|
||||||
if (Result.Val.getBitWidth() > Val.getBitWidth()) {
|
if (Result.Val.getBitWidth() > Val.getBitWidth()) {
|
||||||
Result.Val = Val.extend(Result.Val.getBitWidth());
|
Result.Val = Val.extend(Result.Val.getBitWidth());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user