-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHexagonAsmParser.html
134 lines (102 loc) · 4.26 KB
/
HexagonAsmParser.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html>
<head>
<link rel="Stylesheet" type="text/css" href="style.css">
<title>HexagonAsmParser</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="Reading list"><h2 id="Reading list" class="header"><a href="#Reading list">Reading list</a></h2></div>
<p>
Some of the information might be outdated but the general ideas might still be
useful
</p>
<ul>
<li>
LLVM assembler basics
<ul>
<li>
<a href="https://eli.thegreenplace.net/2012/11/24/life-of-an-instruction-in-llvm">https://eli.thegreenplace.net/2012/11/24/life-of-an-instruction-in-llvm</a>
<li>
<a href="https://www.embecosm.com/appnotes/ean10/ean10-howto-llvmas-1.0.html#idp86952">https://www.embecosm.com/appnotes/ean10/ean10-howto-llvmas-1.0.html#idp86952</a>
</ul>
<li>
Assembler Relaxation and fragments
<ul>
<li>
<a href="https://eli.thegreenplace.net/2013/01/03/assembler-relaxation#id4">https://eli.thegreenplace.net/2013/01/03/assembler-relaxation#id4</a>
</ul>
<li>
Hexagon Assembler overview
<ul>
<li>
Check out Section 3 of Qualcommm Hexagon Utilities User Guide which is
located in Hexagon Document Bundle that came with Hexagon SDK
<li>
Section 3.6 describes vairous directives e.g. .falign
</ul>
</ul>
<div id="Classes and functions"><h2 id="Classes and functions" class="header"><a href="#Classes and functions">Classes and functions</a></h2></div>
<div id="Classes and functions-HexagonAsmParser"><h3 id="HexagonAsmParser" class="header"><a href="#Classes and functions-HexagonAsmParser">HexagonAsmParser</a></h3></div>
<p>
It's important to know that our HexagonAsmParser deals with valid tokens that
are already parsed by AsmParser::parseStatement where our
MatchAndEmitInstruction is called to do further matching.
</p>
<div id="Classes and functions-HexagonAsmParser::MatchAndEmitInstruction"><h3 id="HexagonAsmParser::MatchAndEmitInstruction" class="header"><a href="#Classes and functions-HexagonAsmParser::MatchAndEmitInstruction">HexagonAsmParser::MatchAndEmitInstruction</a></h3></div>
<p>
This function is invoked in AsmParser::parseStatement which does intial parsing
and put parserd HexagonOperand in the <span id="Classes and functions-HexagonAsmParser::MatchAndEmitInstruction-Operands"></span><strong id="Operands">Operands</strong> parameter of our function.
So it means we are only dealing with valid tokens.
</p>
<ol>
<li>
It inherits from MCTargetAsmParser which has MatchAndEmitInstruction function
to be called for instruction parsing and emitting.
<li>
This returns false on success and returns true on failure to match. Matching
Linux main return 0 on success.
<li>
MatchAndEmitInstruction first checks if the current line is already in a
packet
<li>
Adds a 0 Immeidate into the MCB when we first enter the packet, maybe it's
used to denote we that this MCB is holding a packet
<li>
Makes a new MCInst
<li>
Then it calls matchOneInstruction with the new MCInst as the output parameter
when it first encounter a valid token
<li>
MCB.addOperand(MCOperand::createInst(SubInst)); ?
MCB holds all the instructions in our packet(bundle) represented
as a Inst type of MCOperand
<li>
Call matchBundleOptions and finishBundle when we are at the closing bracket.
<li>
In the situation of single instruction, only finishBundle is called.
</ol>
<div id="Classes and functions-HexagonAsmParser::finishBundle"><h3 id="HexagonAsmParser::finishBundle" class="header"><a href="#Classes and functions-HexagonAsmParser::finishBundle">HexagonAsmParser::finishBundle</a></h3></div>
<p>
Prepare MCInstrInfo, MCSubtargetInfo, MCContext, and a new HexagonMCChecker object
to pass to HexagonMCInstrInfo::canonicalizePacket. Emit instruction if everything is
okay.
</p>
<div id="Classes and functions-HexagonOperand"><h3 id="HexagonOperand" class="header"><a href="#Classes and functions-HexagonOperand">HexagonOperand</a></h3></div>
<ul>
<li>
Must be defined before instruction matcher can be created
<li>
Represents a parsed instruction storing types and contents of its operands.
<li>
Corresponds to Operands parameter in MatchAndEmitInstruction function
</ul>
<p>
Why do MCB.addOperand(MCOperand::createImm(0)); if we are already in a packet?
</p>
<p>
opcode is not used?
</p>
</body>
</html>