Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: src/IceTargetLowering.cpp

Issue 265703002: Add Om1 lowering with no optimizations (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Merge changed from Karl's committed CL Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTargetLowering.h ('k') | src/IceTargetLoweringX8632.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering implementation --===//
2 //
3 // The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the skeleton of the TargetLowering class,
11 // specifically invoking the appropriate lowering method for a given
12 // instruction kind and driving global register allocation. It also
13 // implements the non-deleted instruction iteration in
14 // LoweringContext.
15 //
16 //===----------------------------------------------------------------------===//
17
18 #include "IceCfg.h" // setError()
19 #include "IceCfgNode.h"
20 #include "IceOperand.h"
21 #include "IceTargetLowering.h"
22 #include "IceTargetLoweringX8632.h"
23
24 namespace Ice {
25
26 void LoweringContext::init(CfgNode *N) {
27 Node = N;
28 Cur = getNode()->getInsts().begin();
29 End = getNode()->getInsts().end();
30 skipDeleted(Cur);
31 Next = Cur;
32 advance(Next);
33 }
34
35 void LoweringContext::insert(Inst *Inst) {
36 getNode()->getInsts().insert(Next, Inst);
37 Inst->updateVars(getNode());
38 }
39
40 void LoweringContext::skipDeleted(InstList::iterator &I) {
41 while (I != End && (*I)->isDeleted())
42 ++I;
43 }
44
45 void LoweringContext::advance(InstList::iterator &I) {
46 if (I != End) {
47 ++I;
48 skipDeleted(I);
49 }
50 }
51
52 TargetLowering *TargetLowering::createLowering(TargetArch Target, Cfg *Func) {
53 // These statements can be #ifdef'd to specialize the code generator
54 // to a subset of the available targets. TODO: use CRTP.
55 if (Target == Target_X8632)
56 return TargetX8632::create(Func);
57 #if 0
58 if (Target == Target_X8664)
59 return IceTargetX8664::create(Func);
60 if (Target == Target_ARM32)
61 return IceTargetARM32::create(Func);
62 if (Target == Target_ARM64)
63 return IceTargetARM64::create(Func);
64 #endif
65 Func->setError("Unsupported target");
66 return NULL;
67 }
68
69 // Lowers a single instruction according to the information in
70 // Context, by checking the Context.Cur instruction kind and calling
71 // the appropriate lowering method. The lowering method should insert
72 // target instructions at the Cur.Next insertion point, and should not
73 // delete the Context.Cur instruction or advance Context.Cur.
74 //
75 // The lowering method may look ahead in the instruction stream as
76 // desired, and lower additional instructions in conjunction with the
77 // current one, for example fusing a compare and branch. If it does,
78 // it should advance Context.Cur to point to the next non-deleted
79 // instruction to process, and it should delete any additional
80 // instructions it consumes.
81 void TargetLowering::lower() {
82 assert(!Context.atEnd());
83 Inst *Inst = *Context.getCur();
84 switch (Inst->getKind()) {
85 case Inst::Alloca:
86 lowerAlloca(llvm::dyn_cast<InstAlloca>(Inst));
87 break;
88 case Inst::Arithmetic:
89 lowerArithmetic(llvm::dyn_cast<InstArithmetic>(Inst));
90 break;
91 case Inst::Assign:
92 lowerAssign(llvm::dyn_cast<InstAssign>(Inst));
93 break;
94 case Inst::Br:
95 lowerBr(llvm::dyn_cast<InstBr>(Inst));
96 break;
97 case Inst::Call:
98 lowerCall(llvm::dyn_cast<InstCall>(Inst));
99 break;
100 case Inst::Cast:
101 lowerCast(llvm::dyn_cast<InstCast>(Inst));
102 break;
103 case Inst::Fcmp:
104 lowerFcmp(llvm::dyn_cast<InstFcmp>(Inst));
105 break;
106 case Inst::Icmp:
107 lowerIcmp(llvm::dyn_cast<InstIcmp>(Inst));
108 break;
109 case Inst::Load:
110 lowerLoad(llvm::dyn_cast<InstLoad>(Inst));
111 break;
112 case Inst::Phi:
113 lowerPhi(llvm::dyn_cast<InstPhi>(Inst));
114 break;
115 case Inst::Ret:
116 lowerRet(llvm::dyn_cast<InstRet>(Inst));
117 break;
118 case Inst::Select:
119 lowerSelect(llvm::dyn_cast<InstSelect>(Inst));
120 break;
121 case Inst::Store:
122 lowerStore(llvm::dyn_cast<InstStore>(Inst));
123 break;
124 case Inst::Switch:
125 lowerSwitch(llvm::dyn_cast<InstSwitch>(Inst));
126 break;
127 case Inst::Unreachable:
128 lowerUnreachable(llvm::dyn_cast<InstUnreachable>(Inst));
129 break;
130 case Inst::FakeDef:
131 case Inst::FakeUse:
132 case Inst::FakeKill:
133 case Inst::Target:
134 // These are all Target instruction types and shouldn't be
135 // encountered at this stage.
136 Func->setError("Can't lower unsupported instruction type");
137 break;
138 }
139 Inst->setDeleted();
140
141 postLower();
142
143 Context.advanceCur();
144 Context.advanceNext();
145 }
146
147 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLowering.h ('k') | src/IceTargetLoweringX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698