diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2008-08-04 16:51:22 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2008-08-04 16:51:22 +0000 |
| commit | 88402ce8d064b53cf3d12e782a7b102a285e587e (patch) | |
| tree | 0cd99bc29bf98e54c68780860614b57c0c580e89 /clang/lib/CodeGen/CodeGenFunction.h | |
| parent | 7adf07608847865d47fa50640c3b18007953c4aa (diff) | |
| download | bcm5719-llvm-88402ce8d064b53cf3d12e782a7b102a285e587e.tar.gz bcm5719-llvm-88402ce8d064b53cf3d12e782a7b102a285e587e.zip | |
Add CodeGen support for indirect goto.
- Follows emission scheme used by llvm-gcc, i.e. invent an id for
each label whose address is taken and replace each indirect goto by
a switch to each possible target.
- Currently we emit a switch for each indirect goto instead of
merging them as llvm-gcc does.
llvm-svn: 54318
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 38e10e90cef..374cdf6cd7b 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -22,6 +22,7 @@ #include "clang/AST/ExprObjC.h" #include <vector> +#include <map> namespace llvm { class Module; @@ -240,11 +241,21 @@ public: /// AllocaInsertPoint - This is an instruction in the entry block before which /// we prefer to insert allocas. llvm::Instruction *AllocaInsertPt; - + const llvm::Type *LLVMIntTy; uint32_t LLVMPointerWidth; private: + /// LabelIDs - Track arbitrary ids assigned to labels for use in + /// implementing the GCC address-of-label extension and indirect + /// goto. IDs are assigned to labels inside getIDForAddrOfLabel(). + std::map<const LabelStmt*, unsigned> LabelIDs; + + /// IndirectSwitches - Record the list of switches for indirect + /// gotos. Emission of the actual switching code needs to be delayed + /// until all AddrLabelExprs have been seen. + std::vector<llvm::SwitchInst*> IndirectSwitches; + /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C /// decls. llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap; @@ -342,6 +353,8 @@ public: /// the input field number being accessed. static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts); + unsigned GetIDForAddrOfLabel(const LabelStmt *L); + //===--------------------------------------------------------------------===// // Declaration Emission //===--------------------------------------------------------------------===// @@ -363,6 +376,7 @@ public: void EmitLabel(const LabelStmt &S); // helper for EmitLabelStmt. void EmitLabelStmt(const LabelStmt &S); void EmitGotoStmt(const GotoStmt &S); + void EmitIndirectGotoStmt(const IndirectGotoStmt &S); void EmitIfStmt(const IfStmt &S); void EmitWhileStmt(const WhileStmt &S); void EmitDoStmt(const DoStmt &S); @@ -502,6 +516,15 @@ public: llvm::GlobalValue *GenerateStaticBlockVarDecl(const VarDecl &D, bool NoInit, const char *Separator); + + //===--------------------------------------------------------------------===// + // Internal Helpers + //===--------------------------------------------------------------------===// + +private: + /// EmitIndirectSwitches - Emit code for all of the switch + /// instructions in IndirectSwitches. + void EmitIndirectSwitches(); }; } // end namespace CodeGen } // end namespace clang |

