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

Side by Side Diff: lib/Target/Mips/MipsMCInstLower.cpp

Issue 27690005: [MIPS] Modify LongBranch expansion to work with sandboxing (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 2 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
OLDNEW
1 //===-- MipsMCInstLower.cpp - Convert Mips MachineInstr to MCInst ---------===// 1 //===-- MipsMCInstLower.cpp - Convert Mips MachineInstr to MCInst ---------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file contains code to lower Mips MachineInstrs to their corresponding 10 // This file contains code to lower Mips MachineInstrs to their corresponding
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 case MachineOperand::MO_ConstantPoolIndex: 145 case MachineOperand::MO_ConstantPoolIndex:
146 case MachineOperand::MO_BlockAddress: 146 case MachineOperand::MO_BlockAddress:
147 return LowerSymbolOperand(MO, MOTy, offset); 147 return LowerSymbolOperand(MO, MOTy, offset);
148 case MachineOperand::MO_RegisterMask: 148 case MachineOperand::MO_RegisterMask:
149 break; 149 break;
150 } 150 }
151 151
152 return MCOperand(); 152 return MCOperand();
153 } 153 }
154 154
155 // @LOCALMOD-START
156 void MipsMCInstLower::LowerLongBranchLUi(const MachineInstr *MI,
157 MCInst &OutMI) const {
158 OutMI.setOpcode(Mips::LUi);
159
160 // Lower register operand.
161 MCOperand Reg = LowerOperand(MI->getOperand(0));
162 if (Reg.isValid())
163 OutMI.addOperand(Reg);
164
165 // Lower branch target.
166 const MCSymbol *Symbol = MI->getOperand(1).getMBB()->getSymbol();
167 const MCSymbolRefExpr *MCSym
168 = MCSymbolRefExpr::Create(Symbol,
169 MCSymbolRefExpr::VK_Mips_NACL_LONG_BRANCH_HI16,
170 *Ctx);
171 MCOperand Br = MCOperand::CreateExpr(MCSym);
172 if (Br.isValid())
173 OutMI.addOperand(Br);
174 }
175
176 void MipsMCInstLower::LowerLongBranchADDiu(const MachineInstr *MI,
177 MCInst &OutMI) const {
178 OutMI.setOpcode(Mips::ADDiu);
179
180 // Lower two register operands.
181 for (unsigned i = 0, e = 2; i != e; ++i) {
182 const MachineOperand &MO = MI->getOperand(i);
183 MCOperand Reg = LowerOperand(MO);
184
185 if (Reg.isValid())
186 OutMI.addOperand(Reg);
187 }
188
189 // Lower branch target.
190 const MCSymbol *Symbol = MI->getOperand(2).getMBB()->getSymbol();
191 const MCSymbolRefExpr *MCSym
192 = MCSymbolRefExpr::Create(Symbol,
193 MCSymbolRefExpr::VK_Mips_NACL_LONG_BRANCH_LO16,
194 *Ctx);
195 MCOperand Br = MCOperand::CreateExpr(MCSym);
196 if (Br.isValid())
197 OutMI.addOperand(Br);
198 }
199 // @LOCALMOD-END
200
155 void MipsMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const { 201 void MipsMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
202 // @LOCALMOD-START
203 if (AsmPrinter.Subtarget->isTargetNaCl()) {
204 if (MI->getOpcode() == Mips::LUi
205 && (MI->getOperand(1).getTargetFlags()
206 == MipsII::MO_NACL_LONG_BRANCH)) {
207 LowerLongBranchLUi(MI, OutMI);
208 return;
209 }
210 if (MI->getOpcode() == Mips::ADDiu
211 && (MI->getOperand(2).getTargetFlags()
212 == MipsII::MO_NACL_LONG_BRANCH)) {
213 LowerLongBranchADDiu(MI, OutMI);
214 return;
215 }
216 }
217 // @LOCALMOD-END
218
156 OutMI.setOpcode(MI->getOpcode()); 219 OutMI.setOpcode(MI->getOpcode());
157 220
158 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { 221 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
159 const MachineOperand &MO = MI->getOperand(i); 222 const MachineOperand &MO = MI->getOperand(i);
160 MCOperand MCOp = LowerOperand(MO); 223 MCOperand MCOp = LowerOperand(MO);
161 224
162 if (MCOp.isValid()) 225 if (MCOp.isValid())
163 OutMI.addOperand(MCOp); 226 OutMI.addOperand(MCOp);
164 } 227 }
165 } 228 }
166 229
OLDNEW
« lib/Target/Mips/MipsLongBranch.cpp ('K') | « lib/Target/Mips/MipsMCInstLower.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698