Skip to content
Snippets Groups Projects
Commit 31ad893c authored by kotsifa2's avatar kotsifa2
Browse files

1. Type information in dataflow edges

2. Launch intrinsic
   Right now the graph builder pass is outdated,
   more changes are required.
parent 26394da1
No related branches found
No related tags found
No related merge requests found
...@@ -320,17 +320,19 @@ private: ...@@ -320,17 +320,19 @@ private:
Function* ArgMapFuncPointer; ///< Function that associates the input Function* ArgMapFuncPointer; ///< Function that associates the input
///< arguments of destination with the outputs ///< arguments of destination with the outputs
///< of source dataflow node ///< of source dataflow node
Type* ArgType;
// Functions // Functions
DFEdge(DFNode* _SrcDF, DFNode* _DestDF, Function* _DFMapFuncPointer, DFEdge(DFNode* _SrcDF, DFNode* _DestDF, Function* _DFMapFuncPointer,
Function* _ArgMapFuncPointer) : SrcDF(_SrcDF), DestDF(_DestDF), Function* _ArgMapFuncPointer, Type* _ArgType) : SrcDF(_SrcDF),
DFMapFuncPointer(_DFMapFuncPointer), DestDF(_DestDF), DFMapFuncPointer(_DFMapFuncPointer),
ArgMapFuncPointer(_ArgMapFuncPointer) {} ArgMapFuncPointer(_ArgMapFuncPointer), ArgType(_ArgType) {}
public: public:
static DFEdge *Create(DFNode* SrcDF, DFNode* DestDF, Function* DFMapFuncPtr, static DFEdge *Create(DFNode* SrcDF, DFNode* DestDF, Function* DFMapFuncPtr,
Function* ArgMapFuncPtr) { Function* ArgMapFuncPtr, Type* ArgType) {
return new DFEdge(SrcDF, DestDF, DFMapFuncPtr, ArgMapFuncPtr); return new DFEdge(SrcDF, DestDF, DFMapFuncPtr, ArgMapFuncPtr, ArgType);
} }
}; };
......
...@@ -17,6 +17,12 @@ let TargetPrefix = "visc" in { ...@@ -17,6 +17,12 @@ let TargetPrefix = "visc" in {
* worst memory behavior for all these intrinsics. * worst memory behavior for all these intrinsics.
*/ */
/* Launch intrinsic -
* i8* llvm.visc.launch(i8*, i8*, int);
*/
def int_visc_launch : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_ptr_ty,
llvm_i32_ty], []>;
/* Create Node intrinsic - /* Create Node intrinsic -
* i8* llvm.visc.createNode(function*); * i8* llvm.visc.createNode(function*);
*/ */
...@@ -44,10 +50,11 @@ let TargetPrefix = "visc" in { ...@@ -44,10 +50,11 @@ let TargetPrefix = "visc" in {
[]>; []>;
/* Create dataflow edge intrinsic - /* Create dataflow edge intrinsic -
* i8* llvm.visc.createEdge(i8*, i8*, funtion*, function*); * i8* llvm.visc.createEdge(i8*, i8*, function*, function*, instr*);
*/ */
def int_visc_createEdge : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_ptr_ty, def int_visc_createEdge : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_ptr_ty,
llvm_ptr_ty, llvm_ptr_ty], []>; llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
[]>;
/* Find associated dataflow node intrinsic - /* Find associated dataflow node intrinsic -
* i8* llvm.visc.getNode(); * i8* llvm.visc.getNode();
......
...@@ -45,12 +45,17 @@ namespace { ...@@ -45,12 +45,17 @@ namespace {
// Functions // Functions
bool isViscIntrinsic(Instruction * I); bool isViscGraphIntrinsic(Instruction * I);
void handleCreateNode (DFInternalNode* N, IntrinsicInst* II); void handleCreateNode (DFInternalNode* N, IntrinsicInst* II);
void handleCreateEdge (DFInternalNode* N, IntrinsicInst* II); void handleCreateEdge (DFInternalNode* N, IntrinsicInst* II);
//TODO: Fix so that launch is detected as an entry point of builder pass,
// not just as an intrinsic
void handleLaunch (DFInternalNode* N, IntrinsicInst* II);
void BuildGraph (DFInternalNode* N, Function* F); void BuildGraph (DFInternalNode* N, Function* F);
//TODO: Fix so that launch is detected as an entry point of builder pass,
// not just as an intrinsic
public: public:
virtual bool runOnModule(Module &M) { virtual bool runOnModule(Module &M) {
...@@ -82,7 +87,7 @@ namespace { ...@@ -82,7 +87,7 @@ namespace {
}; };
// Returns true if the instruction I is a visc intrinsic, false otherwise // Returns true if the instruction I is a visc intrinsic, false otherwise
bool BuildDFG::isViscIntrinsic(Instruction* I) { bool BuildDFG::isViscGraphIntrinsic(Instruction* I) {
if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(I)) { if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(I)) {
if (((II->getCalledFunction()->getName()).startswith("llvm.visc.create"))) { if (((II->getCalledFunction()->getName()).startswith("llvm.visc.create"))) {
// It is a visc intrinsic // It is a visc intrinsic
...@@ -102,7 +107,7 @@ namespace { ...@@ -102,7 +107,7 @@ namespace {
// internal node // internal node
for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i) { for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i) {
Instruction* I = &*i; // Grab pointer to Instruction Instruction* I = &*i; // Grab pointer to Instruction
if (isViscIntrinsic(I)) if (isViscGraphIntrinsic(I))
isInternalNode = true; isInternalNode = true;
} }
...@@ -143,7 +148,14 @@ namespace { ...@@ -143,7 +148,14 @@ namespace {
DFNode* DestDF = HandleToDFNodeMap[II->getOperand(1)]; DFNode* DestDF = HandleToDFNodeMap[II->getOperand(1)];
Function* DFMapFunc = cast<Function>((II->getOperand(2))->stripPointerCasts()); Function* DFMapFunc = cast<Function>((II->getOperand(2))->stripPointerCasts());
Function* ArgMapFunc = cast<Function>((II->getOperand(3))->stripPointerCasts()); Function* ArgMapFunc = cast<Function>((II->getOperand(3))->stripPointerCasts());
DFEdge* newDFEdge = DFEdge::Create(SrcDF, DestDF, DFMapFunc, ArgMapFunc); BitCastInst* BitCastI = cast<BitCastInst>((II->getOperand(4))->stripPointerCasts());
Type* ArgType = BitCastI->getOperand(0)->getType();
DFEdge* newDFEdge = DFEdge::Create(SrcDF,
DestDF,
DFMapFunc,
ArgMapFunc,
ArgType);
HandleToDFEdgeMap[II] = newDFEdge; HandleToDFEdgeMap[II] = newDFEdge;
...@@ -157,6 +169,13 @@ namespace { ...@@ -157,6 +169,13 @@ namespace {
} }
void BuildDFG::handleLaunch(DFInternalNode* N, IntrinsicInst* II) {
Function* F = cast<Function>((II->getOperand(0))->stripPointerCasts());
Root = DFInternalNode::Create(II, F);
BuildGraph(Root, F);
}
void BuildDFG::BuildGraph (DFInternalNode* N, Function *F) { void BuildDFG::BuildGraph (DFInternalNode* N, Function *F) {
// TODO: Place checks for valid visc functions. For example one of the // TODO: Place checks for valid visc functions. For example one of the
...@@ -186,6 +205,12 @@ namespace { ...@@ -186,6 +205,12 @@ namespace {
handleCreateEdge(N, II); handleCreateEdge(N, II);
break; break;
//TODO: ERASE (just to check that the function is called)
case Intrinsic::visc_launch:
errs() << "Error: Launch intrinsic used in graph\n";
handleLaunch(NULL, II);
break;
default: default:
errs() << "Error: Invalid VISC Intrinsic\n"; errs() << "Error: Invalid VISC Intrinsic\n";
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment