2011年3月16日 星期三

DFG @ c++

如果你對 llvm 很熟的話. 那麼這篇你看了應該會吐血....因為....小弟沒把 Reference manual 看熟,就自己硬幹底層的 class 導致跟 frond end 的 llvm interface 接起來有點醜. 感覺是小弟自己重複定義了 llvm 已有的 class. 如 llvm 中的 Instruction 可用 dyn_cast 的方式轉成 binary operator 跟 Value 的型態. 而我們定義了 Node, Edge 來描述 Instruction 的結構.... 類似的情況. 而 llvm 可以藉由自己定義的 library 來改變 IR. 而我們是改變 Graph 的 type... 反正就是一個字來形容 "" .XD 主要的問題就是在於 llvm 是用 Transport Triggered Architecture 的方式來 link dependent instruction. 就 (tmp3+tmp1)>>1 的結果而言. llvm 會把 tmp3+tmp1 的結果(%add) 的 pointer 指向 next dependent 的 instruction. 且 (%add) 的 result 沒有 API 可以 Get. 雖然可以用 iterator 從最後一個 Instruction 把每個 Instruction 的關係找出來. 但這樣好像有點暴力...
%add = add nsw i32 %tmp3, %tmp1
%shr = ashr i32 %add, 1
還好有提早發現到這個問題,不然再繼續走下去.會更加吐血吧... project: https://github.com/funningboy/XVerilog/blob/master/main.cpp 目前完成 Node : 定義每個 hardware resource ex: reg, alu, mem .... Edge : 定義每個 hardware resource 彼此的相依關係 ex: prelist, nxtlist... Graph : 定義個Basic Blcok內的 Node, Edge. cycle check : 針對每個 instruction 的 Delay 來判斷是否要插入 reg schedule : ASAP/ALAP refs: TCE project: Co-design of application-specific processors with LLVM-based compilation support How do I get the result of an instruction?

沒有留言:

張貼留言