Add support for function pointers.

Both uniform and varying function pointers are supported; when a function
is called through a varying function pointer, each unique function pointer
value across the running program instances is called once for the set of
active program instances that want to call it.
This commit is contained in:
Matt Pharr
2011-11-03 16:13:27 -07:00
parent f1d8ff96ce
commit afcd42028f
15 changed files with 1137 additions and 269 deletions

18
expr.h
View File

@@ -490,6 +490,7 @@ public:
Expr *TypeCheck();
Expr *Optimize();
int EstimateCost() const;
llvm::Constant *GetConstant(const Type *type) const;
const Type *type;
Expr *expr;
@@ -568,6 +569,7 @@ public:
Expr *Optimize();
void Print() const;
int EstimateCost() const;
llvm::Constant *GetConstant(const Type *type) const;
bool ResolveOverloads(const std::vector<const Type *> &argTypes);
Symbol *GetMatchingFunction();
@@ -586,6 +588,8 @@ private:
/** The actual matching function found after overload resolution. */
Symbol *matchingFunc;
bool triedToResolve;
};
@@ -604,6 +608,20 @@ public:
};
/** @brief An expression that represents a NULL pointer. */
class NullPointerExpr : public Expr {
public:
NullPointerExpr(SourcePos p) : Expr(p) { }
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
const Type *GetType() const;
Expr *TypeCheck();
Expr *Optimize();
void Print() const;
int EstimateCost() const;
};
/** This function indicates whether it's legal to convert from fromType to
toType.
*/