Files
clang-p2996/clang/CodeGen/CodeGenModule.h
Chris Lattner b6984c4854 Hook up global function and variable handling. We can now compile:
int X, bar(int,int,int);
short Y;

double foo() {
  return bar(X, Y, 3);
}

into:

@X = external global i32                ; <i32*> [#uses=1]
@Y = external global i16                ; <i16*> [#uses=1]

define double @foo() {
entry:
        %tmp = load i32* @X             ; <i32> [#uses=1]
        %tmp1 = load i16* @Y            ; <i16> [#uses=1]
        %promote = sext i16 %tmp1 to i32                ; <i32> [#uses=1]
        %call = tail call i32 @bar( i32 %tmp, i32 %promote, i32 3 )             ; <i32> [#uses=1]
        %conv = sitofp i32 %call to double              ; <double> [#uses=1]
        ret double %conv
}

declare i32 @bar(i32, i32, i32)

llvm-svn: 39663
2007-06-20 04:44:43 +00:00

57 lines
1.5 KiB
C++

//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen --------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the internal per-translation-unit state used for llvm translation.
//
//===----------------------------------------------------------------------===//
#ifndef CODEGEN_CODEGENMODULE_H
#define CODEGEN_CODEGENMODULE_H
#include "CodeGenTypes.h"
#include "llvm/ADT/DenseMap.h"
namespace llvm {
class Module;
class Constant;
}
namespace clang {
class ASTContext;
class FunctionDecl;
class Decl;
namespace CodeGen {
/// CodeGenModule - This class organizes the cross-module state that is used
/// while generating LLVM code.
class CodeGenModule {
ASTContext &Context;
llvm::Module &TheModule;
CodeGenTypes Types;
llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
public:
CodeGenModule(ASTContext &C, llvm::Module &M);
ASTContext &getContext() const { return Context; }
llvm::Module &getModule() const { return TheModule; }
CodeGenTypes &getTypes() { return Types; }
llvm::Constant *GetAddrOfGlobalDecl(const Decl *D);
void EmitFunction(FunctionDecl *FD);
void PrintStats() {}
};
} // end namespace CodeGen
} // end namespace clang
#endif