mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-03 18:32:50 +00:00
For PR1090:
Clean up the definitions of the helper functions per Chris' review suggestions so they are easier to read. For PR1091: Print minimum signed integer values as unsigned so that we get no warnings from the C compiler about constant ranges and value comparisons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33010 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b75137d1f4
commit
fbe7ae9e3c
@ -826,23 +826,26 @@ void CWriter::printConstant(Constant *CPV) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (CPV->getType()->getTypeID()) {
|
||||
case Type::BoolTyID:
|
||||
Out << (cast<ConstantBool>(CPV)->getValue() ? '1' : '0');
|
||||
break;
|
||||
case Type::Int8TyID:
|
||||
Out << "((char)" << cast<ConstantInt>(CPV)->getSExtValue() << ")";
|
||||
break;
|
||||
case Type::Int16TyID:
|
||||
Out << "((short)" << cast<ConstantInt>(CPV)->getSExtValue() << ")";
|
||||
break;
|
||||
case Type::Int32TyID:
|
||||
Out << "((int)" << cast<ConstantInt>(CPV)->getSExtValue() << ")";
|
||||
break;
|
||||
case Type::Int64TyID:
|
||||
Out << "((long long)" << cast<ConstantInt>(CPV)->getSExtValue() << "ll)";
|
||||
break;
|
||||
if (ConstantBool *CB = dyn_cast<ConstantBool>(CPV)) {
|
||||
Out << (CB->getValue() ? '1' : '0') ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(CPV)) {
|
||||
const Type* Ty = CI->getType();
|
||||
Out << "((";
|
||||
printPrimitiveType(Out, Ty, true) << ')';
|
||||
if (CI->isMinValue(true))
|
||||
Out << CI->getZExtValue() << 'u';
|
||||
else
|
||||
Out << CI->getSExtValue();
|
||||
if (Ty->getPrimitiveSizeInBits() > 32)
|
||||
Out << "ll";
|
||||
Out << ')';
|
||||
return;
|
||||
}
|
||||
|
||||
switch (CPV->getType()->getTypeID()) {
|
||||
case Type::FloatTyID:
|
||||
case Type::DoubleTyID: {
|
||||
ConstantFP *FPC = cast<ConstantFP>(CPV);
|
||||
@ -1586,29 +1589,29 @@ bool CWriter::doInitialization(Module &M) {
|
||||
Out << "static inline int llvm_fcmp_uno(double X, double Y) { ";
|
||||
Out << "return X != X || Y != Y; }\n";
|
||||
Out << "static inline int llvm_fcmp_ueq(double X, double Y) { ";
|
||||
Out << "return X == Y || X != X || Y != Y; }\n";
|
||||
Out << "return X == Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_une(double X, double Y) { ";
|
||||
Out << "return X != Y || X != X || Y != Y; }\n";
|
||||
Out << "return X != Y; }\n";
|
||||
Out << "static inline int llvm_fcmp_ult(double X, double Y) { ";
|
||||
Out << "return X < Y || X != X || Y != Y; }\n";
|
||||
Out << "return X < Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_ugt(double X, double Y) { ";
|
||||
Out << "return X > Y || X != X || Y != Y; }\n";
|
||||
Out << "return X > Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_ule(double X, double Y) { ";
|
||||
Out << "return X <= Y || X != X || Y != Y; }\n";
|
||||
Out << "return X <= Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_uge(double X, double Y) { ";
|
||||
Out << "return X >= Y || X != X || Y != Y; }\n";
|
||||
Out << "return X >= Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_oeq(double X, double Y) { ";
|
||||
Out << "return X == Y && X == X && Y == Y; }\n";
|
||||
Out << "return X == Y ; }\n";
|
||||
Out << "static inline int llvm_fcmp_one(double X, double Y) { ";
|
||||
Out << "return X != Y && X == X && Y == Y; }\n";
|
||||
Out << "return X != Y && llvm_fcmp_ord(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_olt(double X, double Y) { ";
|
||||
Out << "return X < Y && X == X && Y == Y; }\n";
|
||||
Out << "return X < Y ; }\n";
|
||||
Out << "static inline int llvm_fcmp_ogt(double X, double Y) { ";
|
||||
Out << "return X > Y && X == X && Y == Y; }\n";
|
||||
Out << "return X > Y ; }\n";
|
||||
Out << "static inline int llvm_fcmp_ole(double X, double Y) { ";
|
||||
Out << "return X <= Y && X == X && Y == Y; }\n";
|
||||
Out << "return X <= Y ; }\n";
|
||||
Out << "static inline int llvm_fcmp_oge(double X, double Y) { ";
|
||||
Out << "return X >= Y && X == X && Y == Y; }\n";
|
||||
Out << "return X >= Y ; }\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -826,23 +826,26 @@ void CWriter::printConstant(Constant *CPV) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (CPV->getType()->getTypeID()) {
|
||||
case Type::BoolTyID:
|
||||
Out << (cast<ConstantBool>(CPV)->getValue() ? '1' : '0');
|
||||
break;
|
||||
case Type::Int8TyID:
|
||||
Out << "((char)" << cast<ConstantInt>(CPV)->getSExtValue() << ")";
|
||||
break;
|
||||
case Type::Int16TyID:
|
||||
Out << "((short)" << cast<ConstantInt>(CPV)->getSExtValue() << ")";
|
||||
break;
|
||||
case Type::Int32TyID:
|
||||
Out << "((int)" << cast<ConstantInt>(CPV)->getSExtValue() << ")";
|
||||
break;
|
||||
case Type::Int64TyID:
|
||||
Out << "((long long)" << cast<ConstantInt>(CPV)->getSExtValue() << "ll)";
|
||||
break;
|
||||
if (ConstantBool *CB = dyn_cast<ConstantBool>(CPV)) {
|
||||
Out << (CB->getValue() ? '1' : '0') ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(CPV)) {
|
||||
const Type* Ty = CI->getType();
|
||||
Out << "((";
|
||||
printPrimitiveType(Out, Ty, true) << ')';
|
||||
if (CI->isMinValue(true))
|
||||
Out << CI->getZExtValue() << 'u';
|
||||
else
|
||||
Out << CI->getSExtValue();
|
||||
if (Ty->getPrimitiveSizeInBits() > 32)
|
||||
Out << "ll";
|
||||
Out << ')';
|
||||
return;
|
||||
}
|
||||
|
||||
switch (CPV->getType()->getTypeID()) {
|
||||
case Type::FloatTyID:
|
||||
case Type::DoubleTyID: {
|
||||
ConstantFP *FPC = cast<ConstantFP>(CPV);
|
||||
@ -1586,29 +1589,29 @@ bool CWriter::doInitialization(Module &M) {
|
||||
Out << "static inline int llvm_fcmp_uno(double X, double Y) { ";
|
||||
Out << "return X != X || Y != Y; }\n";
|
||||
Out << "static inline int llvm_fcmp_ueq(double X, double Y) { ";
|
||||
Out << "return X == Y || X != X || Y != Y; }\n";
|
||||
Out << "return X == Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_une(double X, double Y) { ";
|
||||
Out << "return X != Y || X != X || Y != Y; }\n";
|
||||
Out << "return X != Y; }\n";
|
||||
Out << "static inline int llvm_fcmp_ult(double X, double Y) { ";
|
||||
Out << "return X < Y || X != X || Y != Y; }\n";
|
||||
Out << "return X < Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_ugt(double X, double Y) { ";
|
||||
Out << "return X > Y || X != X || Y != Y; }\n";
|
||||
Out << "return X > Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_ule(double X, double Y) { ";
|
||||
Out << "return X <= Y || X != X || Y != Y; }\n";
|
||||
Out << "return X <= Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_uge(double X, double Y) { ";
|
||||
Out << "return X >= Y || X != X || Y != Y; }\n";
|
||||
Out << "return X >= Y || llvm_fcmp_uno(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_oeq(double X, double Y) { ";
|
||||
Out << "return X == Y && X == X && Y == Y; }\n";
|
||||
Out << "return X == Y ; }\n";
|
||||
Out << "static inline int llvm_fcmp_one(double X, double Y) { ";
|
||||
Out << "return X != Y && X == X && Y == Y; }\n";
|
||||
Out << "return X != Y && llvm_fcmp_ord(X, Y); }\n";
|
||||
Out << "static inline int llvm_fcmp_olt(double X, double Y) { ";
|
||||
Out << "return X < Y && X == X && Y == Y; }\n";
|
||||
Out << "return X < Y ; }\n";
|
||||
Out << "static inline int llvm_fcmp_ogt(double X, double Y) { ";
|
||||
Out << "return X > Y && X == X && Y == Y; }\n";
|
||||
Out << "return X > Y ; }\n";
|
||||
Out << "static inline int llvm_fcmp_ole(double X, double Y) { ";
|
||||
Out << "return X <= Y && X == X && Y == Y; }\n";
|
||||
Out << "return X <= Y ; }\n";
|
||||
Out << "static inline int llvm_fcmp_oge(double X, double Y) { ";
|
||||
Out << "return X >= Y && X == X && Y == Y; }\n";
|
||||
Out << "return X >= Y ; }\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user