[cfe-commits] r39561 - in /cfe/cfe/trunk/CodeGen: CodeGenFunction.cpp CodeGenFunction.h
clattner at cs.uiuc.edu
clattner at cs.uiuc.edu
Wed Jul 11 09:45:37 PDT 2007
Author: clattner
Date: Wed Jul 11 11:45:37 2007
New Revision: 39561
URL: http://llvm.org/viewvc/llvm-project?rev=39561&view=rev
Log:
Implement translation of pointer, reference and simple array types. We now
compile:
void foo() {
int A[10];
int *P;
into:
entry:
%A = alloca [10 x i32] ; <[10 x i32]*> [#uses=0]
%P = alloca i32* ; <i32**> [#uses=0]
Modified:
cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp
cfe/cfe/trunk/CodeGen/CodeGenFunction.h
Modified: cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp?rev=39561&r1=39560&r2=39561&view=diff
==============================================================================
--- cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/cfe/trunk/CodeGen/CodeGenFunction.cpp Wed Jul 11 11:45:37 2007
@@ -81,10 +81,28 @@
}
break;
}
- case Type::Pointer:
- case Type::Reference:
- case Type::Array:
- break;
+ case Type::Pointer: {
+ const PointerType &P = cast<PointerType>(Ty);
+ return llvm::PointerType::get(ConvertType(P.getPointeeType(), Loc));
+ }
+ case Type::Reference: {
+ const ReferenceType &R = cast<ReferenceType>(Ty);
+ return llvm::PointerType::get(ConvertType(R.getReferenceeType(), Loc));
+ }
+
+ case Type::Array: {
+ const ArrayType &A = cast<ArrayType>(Ty);
+ assert(A.getSizeModifier() == ArrayType::Normal &&
+ A.getIndexTypeQualifier() == 0 &&
+ "FIXME: We only handle trivial array types so far!");
+ // FIXME: are there any promotions etc here?
+ ExprResult Size = EmitExpr(A.getSize());
+ assert(Size.isScalar() && isa<llvm::ConstantInt>(Size.getVal()) &&
+ "FIXME: Only handle fixed-size arrays so far");
+ const llvm::Type *EltTy = ConvertType(A.getElementType(), Loc);
+ return llvm::ArrayType::get(EltTy,
+ cast<llvm::ConstantInt>(Size.getVal())->getZExtValue());
+ }
case Type::FunctionNoProto:
case Type::FunctionProto: {
const FunctionType &FP = cast<FunctionType>(Ty);
Modified: cfe/cfe/trunk/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/CodeGen/CodeGenFunction.h?rev=39561&r1=39560&r2=39561&view=diff
==============================================================================
--- cfe/cfe/trunk/CodeGen/CodeGenFunction.h (original)
+++ cfe/cfe/trunk/CodeGen/CodeGenFunction.h Wed Jul 11 11:45:37 2007
@@ -126,8 +126,6 @@
/// LabelMap - This keeps track of the LLVM basic block for each C label.
DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap;
-
- const llvm::Type *LLVMIntTy;
public:
CodeGenFunction(CodeGenModule &cgm);
More information about the cfe-commits
mailing list