implement codegen support for FP literals

llvm-svn: 39718
This commit is contained in:
Chris Lattner 2007-07-09 23:03:16 +00:00
parent 84ff4b44b0
commit 2ada32ed7d
2 changed files with 8 additions and 0 deletions

View File

@ -432,6 +432,8 @@ RValue CodeGenFunction::EmitExpr(const Expr *E) {
// Leaf expressions.
case Expr::IntegerLiteralClass:
return EmitIntegerLiteral(cast<IntegerLiteral>(E));
case Expr::FloatingLiteralClass:
return EmitFloatingLiteral(cast<FloatingLiteral>(E));
// Operators.
case Expr::ParenExprClass:
@ -451,6 +453,10 @@ RValue CodeGenFunction::EmitExpr(const Expr *E) {
RValue CodeGenFunction::EmitIntegerLiteral(const IntegerLiteral *E) {
return RValue::get(llvm::ConstantInt::get(E->getValue()));
}
RValue CodeGenFunction::EmitFloatingLiteral(const FloatingLiteral *E) {
return RValue::get(llvm::ConstantFP::get(ConvertType(E->getType()),
E->getValue()));
}
RValue CodeGenFunction::EmitCastExpr(const CastExpr *E) {
QualType SrcTy;

View File

@ -45,6 +45,7 @@ namespace clang {
class DeclRefExpr;
class StringLiteral;
class IntegerLiteral;
class FloatingLiteral;
class CastExpr;
class CallExpr;
class UnaryOperator;
@ -280,6 +281,7 @@ public:
RValue EmitExpr(const Expr *E);
RValue EmitIntegerLiteral(const IntegerLiteral *E);
RValue EmitFloatingLiteral(const FloatingLiteral *E);
RValue EmitCastExpr(const CastExpr *E);
RValue EmitCallExpr(const CallExpr *E);