[llvm-commits] Target independent VLIW Packetizer
Sundeep
sundeepk at codeaurora.org
Mon Feb 6 00:06:12 PST 2012
Hi All,
I have been working on a target independent VLIW packetizer in LLVM. On VLIW
machines, an instruction packet represents a group of instructions which can
be executed in parallel. The compiler is responsible for identifying
independent machine instructions and grouping those together into packets.
The VLIW packetizer in LLVM is implemented as follows:
Implementation Details:
1. The VLIW packetizer is implemented after all target specific passes are
run. This ensures that all pseudo instructions and spill code is enumerated
before packetization.
2. The VLIW packetizer extends "ScheduleDAGInstrs" class. The Packetizer
uses "BuildSchedGraph" API to build dependence graph. The dependence graph
along with deterministic finite automaton (DFA) is used to group independent
instructions into packets.
3. The instruction packets are finalized using "finalizeBundle" API. This
API inserts BUNDLE instructions and updates each packet instruction with
"insideBundle" bit.
4. The Hexagon backend assembly printer is updated to handle BUNDLE
instruction and print packet semantics correctly. Other VLIW targets will
also have to update the assembly printer.
The VLIW packetizer roughly implements the following algorithm:
1 Instantiate DFA resource tracker
2 For all basic blocks (BB) in Machine Function
3 do
4 reset DFA
5 CurrentPacket = {}
6 For all machine instructions (I) in BB
7 do
8 avail = DFA.IsAvailable(I)
9 if (avail == true) {
10 For all machine instructions (Ip) in CurrentPacket
11 do
12 if (DependenceGraph.HasDependence(I, Ip)) {
13 if (Target.CanPruneDependence(I, Ip)) {
14 // End current packet
15 finalizeBundle
16 reset DFA
17 reset CurrentPacket
18 }
19 }
20 done
21 }
22 else {
23 // End current packet
24 finalizeBundle
25 reset DFA
26 reset CurrentPacket
27 }
28
29 // Add I to CurrentPacket
30 CurrentPacket.Add(I)
31 done
32 done
I have already verified that it builds and runs regression test suites clean
on x86. I attaching the initial patch for review and comments.
Thanks,
Sundeep
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vliw-packetizer-patch.txt
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120206/2285fbb1/attachment.txt>
More information about the llvm-commits
mailing list