Partial CBackend support for 128-bit integers. This is needed

now that llvm-gcc is lowering appropriately-sized struct returns
to i128 on x86-64.

llvm-svn: 49109
This commit is contained in:
Dan Gohman 2008-04-02 19:40:14 +00:00
parent 0ca05878fe
commit 4949a9c308

View File

@ -445,9 +445,11 @@ CWriter::printSimpleType(std::ostream &Out, const Type *Ty, bool isSigned,
return Out << (isSigned?"signed":"unsigned") << " short " << NameSoFar;
else if (NumBits <= 32)
return Out << (isSigned?"signed":"unsigned") << " int " << NameSoFar;
else {
assert(NumBits <= 64 && "Bit widths > 64 not implemented yet");
else if (NumBits <= 64)
return Out << (isSigned?"signed":"unsigned") << " long long "<< NameSoFar;
else {
assert(NumBits <= 128 && "Bit widths > 128 not implemented yet");
return Out << (isSigned?"llvmInt128":"llvmUInt128") << " " << NameSoFar;
}
}
case Type::FloatTyID: return Out << "float " << NameSoFar;
@ -1478,6 +1480,11 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
<< "#define __builtin_stack_restore(X) /* noop */\n"
<< "#endif\n\n";
Out << "#ifdef __GNUC__ /* 128-bit integer types */\n"
<< "typedef int __attribute__((mode(TI))) llvmInt128;\n"
<< "typedef unsigned __attribute__((mode(TI))) llvmUInt128;\n"
<< "#endif\n\n";
// Output target-specific code that should be inserted into main.
Out << "#define CODE_FOR_MAIN() /* Any target-specific code for main()*/\n";
}