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

Side by Side Diff: src/IceTargetLoweringARM32.cpp

Issue 1136793002: Handle ARM "ret void" and function alignment with proper padding. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: rename param Created 5 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
OLDNEW
1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===// 1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
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 implements the TargetLoweringARM32 class, which consists almost 10 // This file implements the TargetLoweringARM32 class, which consists almost
(...skipping 12 matching lines...) Expand all
23 #include "IceInstARM32.h" 23 #include "IceInstARM32.h"
24 #include "IceLiveness.h" 24 #include "IceLiveness.h"
25 #include "IceOperand.h" 25 #include "IceOperand.h"
26 #include "IceRegistersARM32.h" 26 #include "IceRegistersARM32.h"
27 #include "IceTargetLoweringARM32.def" 27 #include "IceTargetLoweringARM32.def"
28 #include "IceTargetLoweringARM32.h" 28 #include "IceTargetLoweringARM32.h"
29 #include "IceUtils.h" 29 #include "IceUtils.h"
30 30
31 namespace Ice { 31 namespace Ice {
32 32
33 namespace {
34 void UnimplementedError(const ClFlags &Flags) {
35 if (!Flags.getSkipUnimplemented()) {
36 // Use llvm_unreachable instead of report_fatal_error, which gives better
37 // stack traces.
38 llvm_unreachable("Not yet implemented");
39 abort();
40 }
41 }
42 } // end of anonymous namespace
43
33 TargetARM32::TargetARM32(Cfg *Func) 44 TargetARM32::TargetARM32(Cfg *Func)
34 : TargetLowering(Func), UsesFramePointer(false) { 45 : TargetLowering(Func), UsesFramePointer(false) {
35 // TODO: Don't initialize IntegerRegisters and friends every time. 46 // TODO: Don't initialize IntegerRegisters and friends every time.
36 // Instead, initialize in some sort of static initializer for the 47 // Instead, initialize in some sort of static initializer for the
37 // class. 48 // class.
38 llvm::SmallBitVector IntegerRegisters(RegARM32::Reg_NUM); 49 llvm::SmallBitVector IntegerRegisters(RegARM32::Reg_NUM);
39 llvm::SmallBitVector FloatRegisters(RegARM32::Reg_NUM); 50 llvm::SmallBitVector FloatRegisters(RegARM32::Reg_NUM);
40 llvm::SmallBitVector VectorRegisters(RegARM32::Reg_NUM); 51 llvm::SmallBitVector VectorRegisters(RegARM32::Reg_NUM);
41 llvm::SmallBitVector InvalidRegisters(RegARM32::Reg_NUM); 52 llvm::SmallBitVector InvalidRegisters(RegARM32::Reg_NUM);
42 ScratchRegs.resize(RegARM32::Reg_NUM); 53 ScratchRegs.resize(RegARM32::Reg_NUM);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 209
199 // Nop insertion 210 // Nop insertion
200 if (Ctx->getFlags().shouldDoNopInsertion()) { 211 if (Ctx->getFlags().shouldDoNopInsertion()) {
201 Func->doNopInsertion(); 212 Func->doNopInsertion();
202 } 213 }
203 } 214 }
204 215
205 bool TargetARM32::doBranchOpt(Inst *I, const CfgNode *NextNode) { 216 bool TargetARM32::doBranchOpt(Inst *I, const CfgNode *NextNode) {
206 (void)I; 217 (void)I;
207 (void)NextNode; 218 (void)NextNode;
208 llvm::report_fatal_error("Not yet implemented"); 219 UnimplementedError(Func->getContext()->getFlags());
220 return false;
209 } 221 }
210 222
211 IceString TargetARM32::RegNames[] = { 223 IceString TargetARM32::RegNames[] = {
212 #define X(val, encode, name, scratch, preserved, stackptr, frameptr, isInt, \ 224 #define X(val, encode, name, scratch, preserved, stackptr, frameptr, isInt, \
213 isFP) \ 225 isFP) \
214 name, 226 name,
215 REGARM32_TABLE 227 REGARM32_TABLE
216 #undef X 228 #undef X
217 }; 229 };
218 230
219 IceString TargetARM32::getRegName(SizeT RegNum, Type Ty) const { 231 IceString TargetARM32::getRegName(SizeT RegNum, Type Ty) const {
220 assert(RegNum < RegARM32::Reg_NUM); 232 assert(RegNum < RegARM32::Reg_NUM);
221 (void)Ty; 233 (void)Ty;
222 return RegNames[RegNum]; 234 return RegNames[RegNum];
223 } 235 }
224 236
225 Variable *TargetARM32::getPhysicalRegister(SizeT RegNum, Type Ty) { 237 Variable *TargetARM32::getPhysicalRegister(SizeT RegNum, Type Ty) {
226 if (Ty == IceType_void) 238 if (Ty == IceType_void)
227 Ty = IceType_i32; 239 Ty = IceType_i32;
228 if (PhysicalRegisters[Ty].empty()) 240 if (PhysicalRegisters[Ty].empty())
229 PhysicalRegisters[Ty].resize(RegARM32::Reg_NUM); 241 PhysicalRegisters[Ty].resize(RegARM32::Reg_NUM);
230 assert(RegNum < PhysicalRegisters[Ty].size()); 242 assert(RegNum < PhysicalRegisters[Ty].size());
231 Variable *Reg = PhysicalRegisters[Ty][RegNum]; 243 Variable *Reg = PhysicalRegisters[Ty][RegNum];
232 if (Reg == nullptr) { 244 if (Reg == nullptr) {
233 Reg = Func->makeVariable(Ty); 245 Reg = Func->makeVariable(Ty);
234 Reg->setRegNum(RegNum); 246 Reg->setRegNum(RegNum);
235 PhysicalRegisters[Ty][RegNum] = Reg; 247 PhysicalRegisters[Ty][RegNum] = Reg;
236 // Specially mark SP as an "argument" so that it is considered 248 // Specially mark SP and LR as an "argument" so that it is considered
237 // live upon function entry. 249 // live upon function entry.
238 if (RegNum == RegARM32::Reg_sp) { 250 if (RegNum == RegARM32::Reg_sp) {
Jim Stichnoth 2015/05/11 20:12:32 Maybe this instead? if (RegNum == RegARM32::Reg_
jvoung (off chromium) 2015/05/11 22:11:51 Done.
239 Func->addImplicitArg(Reg); 251 Func->addImplicitArg(Reg);
240 Reg->setIgnoreLiveness(); 252 Reg->setIgnoreLiveness();
241 } 253 }
254 if (RegNum == RegARM32::Reg_lr) {
255 Func->addImplicitArg(Reg);
256 Reg->setIgnoreLiveness();
257 }
242 } 258 }
243 return Reg; 259 return Reg;
244 } 260 }
245 261
246 void TargetARM32::emitVariable(const Variable *Var) const { 262 void TargetARM32::emitVariable(const Variable *Var) const {
247 Ostream &Str = Ctx->getStrEmit(); 263 Ostream &Str = Ctx->getStrEmit();
248 (void)Var; 264 if (Var->hasReg()) {
249 (void)Str; 265 Str << getRegName(Var->getRegNum(), Var->getType());
250 llvm::report_fatal_error("emitVariable: Not yet implemented"); 266 return;
267 }
268 if (Var->getWeight().isInf()) {
269 llvm::report_fatal_error(
270 "Infinite-weight Variable has no register assigned");
271 }
272 const Type Ty = IceType_i32;
273 int32_t Offset = Var->getStackOffset();
274 if (!hasFramePointer())
275 Offset += getStackAdjustment();
276 if (Offset <= -(1 << InstARM32::kOffset12Bits) ||
Jim Stichnoth 2015/05/11 20:12:31 Should this be "Offset < -(1 << InstARM32::kOffset
jvoung (off chromium) 2015/05/11 22:11:51 Hmm, apparently ARM is sign-magnitude instead of t
Jim Stichnoth 2015/05/12 00:01:45 Thanks. I would also suggest a comment in canHold
jvoung (off chromium) 2015/05/12 16:38:09 Sounds good -- added a comment about sign-magnitud
277 Offset >= 1 << InstARM32::kOffset12Bits) {
278 llvm::report_fatal_error("Illegal stack offset");
279 }
280 Str << "[" << getRegName(getFrameOrStackReg(), Ty) << ", " << Offset << "]";
251 } 281 }
252 282
253 void TargetARM32::lowerArguments() { 283 void TargetARM32::lowerArguments() {
254 llvm::report_fatal_error("lowerArguments: Not yet implemented"); 284 UnimplementedError(Func->getContext()->getFlags());
255 } 285 }
256 286
257 Type TargetARM32::stackSlotType() { return IceType_i32; } 287 Type TargetARM32::stackSlotType() { return IceType_i32; }
258 288
259 void TargetARM32::addProlog(CfgNode *Node) { 289 void TargetARM32::addProlog(CfgNode *Node) {
260 (void)Node; 290 (void)Node;
261 llvm::report_fatal_error("addProlog: Not yet implemented"); 291 UnimplementedError(Func->getContext()->getFlags());
262 } 292 }
263 293
264 void TargetARM32::addEpilog(CfgNode *Node) { 294 void TargetARM32::addEpilog(CfgNode *Node) {
265 (void)Node; 295 (void)Node;
266 llvm::report_fatal_error("addEpilog: Not yet implemented"); 296 UnimplementedError(Func->getContext()->getFlags());
267 } 297 }
268 298
269 llvm::SmallBitVector TargetARM32::getRegisterSet(RegSetMask Include, 299 llvm::SmallBitVector TargetARM32::getRegisterSet(RegSetMask Include,
270 RegSetMask Exclude) const { 300 RegSetMask Exclude) const {
271 llvm::SmallBitVector Registers(RegARM32::Reg_NUM); 301 llvm::SmallBitVector Registers(RegARM32::Reg_NUM);
272 302
273 #define X(val, encode, name, scratch, preserved, stackptr, frameptr, isInt, \ 303 #define X(val, encode, name, scratch, preserved, stackptr, frameptr, isInt, \
274 isFP) \ 304 isFP) \
275 if (scratch && (Include & RegSet_CallerSave)) \ 305 if (scratch && (Include & RegSet_CallerSave)) \
276 Registers[RegARM32::val] = true; \ 306 Registers[RegARM32::val] = true; \
(...skipping 21 matching lines...) Expand all
298 328
299 void TargetARM32::lowerAlloca(const InstAlloca *Inst) { 329 void TargetARM32::lowerAlloca(const InstAlloca *Inst) {
300 UsesFramePointer = true; 330 UsesFramePointer = true;
301 // Conservatively require the stack to be aligned. Some stack 331 // Conservatively require the stack to be aligned. Some stack
302 // adjustment operations implemented below assume that the stack is 332 // adjustment operations implemented below assume that the stack is
303 // aligned before the alloca. All the alloca code ensures that the 333 // aligned before the alloca. All the alloca code ensures that the
304 // stack alignment is preserved after the alloca. The stack alignment 334 // stack alignment is preserved after the alloca. The stack alignment
305 // restriction can be relaxed in some cases. 335 // restriction can be relaxed in some cases.
306 NeedsStackAlignment = true; 336 NeedsStackAlignment = true;
307 (void)Inst; 337 (void)Inst;
308 llvm::report_fatal_error("Not yet implemented"); 338 UnimplementedError(Func->getContext()->getFlags());
309 } 339 }
310 340
311 void TargetARM32::lowerArithmetic(const InstArithmetic *Inst) { 341 void TargetARM32::lowerArithmetic(const InstArithmetic *Inst) {
312 switch (Inst->getOp()) { 342 switch (Inst->getOp()) {
313 case InstArithmetic::_num: 343 case InstArithmetic::_num:
314 llvm_unreachable("Unknown arithmetic operator"); 344 llvm_unreachable("Unknown arithmetic operator");
315 break; 345 break;
316 case InstArithmetic::Add: 346 case InstArithmetic::Add:
317 llvm::report_fatal_error("Not yet implemented"); 347 UnimplementedError(Func->getContext()->getFlags());
318 break; 348 break;
319 case InstArithmetic::And: 349 case InstArithmetic::And:
320 llvm::report_fatal_error("Not yet implemented"); 350 UnimplementedError(Func->getContext()->getFlags());
321 break; 351 break;
322 case InstArithmetic::Or: 352 case InstArithmetic::Or:
323 llvm::report_fatal_error("Not yet implemented"); 353 UnimplementedError(Func->getContext()->getFlags());
324 break; 354 break;
325 case InstArithmetic::Xor: 355 case InstArithmetic::Xor:
326 llvm::report_fatal_error("Not yet implemented"); 356 UnimplementedError(Func->getContext()->getFlags());
327 break; 357 break;
328 case InstArithmetic::Sub: 358 case InstArithmetic::Sub:
329 llvm::report_fatal_error("Not yet implemented"); 359 UnimplementedError(Func->getContext()->getFlags());
330 break; 360 break;
331 case InstArithmetic::Mul: 361 case InstArithmetic::Mul:
332 llvm::report_fatal_error("Not yet implemented"); 362 UnimplementedError(Func->getContext()->getFlags());
333 break; 363 break;
334 case InstArithmetic::Shl: 364 case InstArithmetic::Shl:
335 llvm::report_fatal_error("Not yet implemented"); 365 UnimplementedError(Func->getContext()->getFlags());
336 break; 366 break;
337 case InstArithmetic::Lshr: 367 case InstArithmetic::Lshr:
338 llvm::report_fatal_error("Not yet implemented"); 368 UnimplementedError(Func->getContext()->getFlags());
339 break; 369 break;
340 case InstArithmetic::Ashr: 370 case InstArithmetic::Ashr:
341 llvm::report_fatal_error("Not yet implemented"); 371 UnimplementedError(Func->getContext()->getFlags());
342 break; 372 break;
343 case InstArithmetic::Udiv: 373 case InstArithmetic::Udiv:
344 llvm::report_fatal_error("Not yet implemented"); 374 UnimplementedError(Func->getContext()->getFlags());
345 break; 375 break;
346 case InstArithmetic::Sdiv: 376 case InstArithmetic::Sdiv:
347 llvm::report_fatal_error("Not yet implemented"); 377 UnimplementedError(Func->getContext()->getFlags());
348 break; 378 break;
349 case InstArithmetic::Urem: 379 case InstArithmetic::Urem:
350 llvm::report_fatal_error("Not yet implemented"); 380 UnimplementedError(Func->getContext()->getFlags());
351 break; 381 break;
352 case InstArithmetic::Srem: 382 case InstArithmetic::Srem:
353 llvm::report_fatal_error("Not yet implemented"); 383 UnimplementedError(Func->getContext()->getFlags());
354 break; 384 break;
355 case InstArithmetic::Fadd: 385 case InstArithmetic::Fadd:
356 llvm::report_fatal_error("Not yet implemented"); 386 UnimplementedError(Func->getContext()->getFlags());
357 break; 387 break;
358 case InstArithmetic::Fsub: 388 case InstArithmetic::Fsub:
359 llvm::report_fatal_error("Not yet implemented"); 389 UnimplementedError(Func->getContext()->getFlags());
360 break; 390 break;
361 case InstArithmetic::Fmul: 391 case InstArithmetic::Fmul:
362 llvm::report_fatal_error("Not yet implemented"); 392 UnimplementedError(Func->getContext()->getFlags());
363 break; 393 break;
364 case InstArithmetic::Fdiv: 394 case InstArithmetic::Fdiv:
365 llvm::report_fatal_error("Not yet implemented"); 395 UnimplementedError(Func->getContext()->getFlags());
366 break; 396 break;
367 case InstArithmetic::Frem: 397 case InstArithmetic::Frem:
368 llvm::report_fatal_error("Not yet implemented"); 398 UnimplementedError(Func->getContext()->getFlags());
369 break; 399 break;
370 } 400 }
371 } 401 }
372 402
373 void TargetARM32::lowerAssign(const InstAssign *Inst) { 403 void TargetARM32::lowerAssign(const InstAssign *Inst) {
374 (void)Inst; 404 (void)Inst;
375 llvm::report_fatal_error("Not yet implemented"); 405 UnimplementedError(Func->getContext()->getFlags());
376 } 406 }
377 407
378 void TargetARM32::lowerBr(const InstBr *Inst) { 408 void TargetARM32::lowerBr(const InstBr *Inst) {
379 (void)Inst; 409 (void)Inst;
380 llvm::report_fatal_error("Not yet implemented"); 410 UnimplementedError(Func->getContext()->getFlags());
381 } 411 }
382 412
383 void TargetARM32::lowerCall(const InstCall *Inst) { 413 void TargetARM32::lowerCall(const InstCall *Inst) {
384 (void)Inst; 414 (void)Inst;
385 llvm::report_fatal_error("Not yet implemented"); 415 UnimplementedError(Func->getContext()->getFlags());
386 } 416 }
387 417
388 void TargetARM32::lowerCast(const InstCast *Inst) { 418 void TargetARM32::lowerCast(const InstCast *Inst) {
389 InstCast::OpKind CastKind = Inst->getCastKind(); 419 InstCast::OpKind CastKind = Inst->getCastKind();
390 switch (CastKind) { 420 switch (CastKind) {
391 default: 421 default:
392 Func->setError("Cast type not supported"); 422 Func->setError("Cast type not supported");
393 return; 423 return;
394 case InstCast::Sext: { 424 case InstCast::Sext: {
395 llvm::report_fatal_error("Not yet implemented"); 425 UnimplementedError(Func->getContext()->getFlags());
396 break; 426 break;
397 } 427 }
398 case InstCast::Zext: { 428 case InstCast::Zext: {
399 llvm::report_fatal_error("Not yet implemented"); 429 UnimplementedError(Func->getContext()->getFlags());
400 break; 430 break;
401 } 431 }
402 case InstCast::Trunc: { 432 case InstCast::Trunc: {
403 llvm::report_fatal_error("Not yet implemented"); 433 UnimplementedError(Func->getContext()->getFlags());
404 break; 434 break;
405 } 435 }
406 case InstCast::Fptrunc: 436 case InstCast::Fptrunc:
407 llvm::report_fatal_error("Not yet implemented"); 437 UnimplementedError(Func->getContext()->getFlags());
408 break; 438 break;
409 case InstCast::Fpext: { 439 case InstCast::Fpext: {
410 llvm::report_fatal_error("Not yet implemented"); 440 UnimplementedError(Func->getContext()->getFlags());
411 break; 441 break;
412 } 442 }
413 case InstCast::Fptosi: 443 case InstCast::Fptosi:
414 llvm::report_fatal_error("Not yet implemented"); 444 UnimplementedError(Func->getContext()->getFlags());
415 break; 445 break;
416 case InstCast::Fptoui: 446 case InstCast::Fptoui:
417 llvm::report_fatal_error("Not yet implemented"); 447 UnimplementedError(Func->getContext()->getFlags());
418 break; 448 break;
419 case InstCast::Sitofp: 449 case InstCast::Sitofp:
420 llvm::report_fatal_error("Not yet implemented"); 450 UnimplementedError(Func->getContext()->getFlags());
421 break; 451 break;
422 case InstCast::Uitofp: { 452 case InstCast::Uitofp: {
423 llvm::report_fatal_error("Not yet implemented"); 453 UnimplementedError(Func->getContext()->getFlags());
424 break; 454 break;
425 } 455 }
426 case InstCast::Bitcast: { 456 case InstCast::Bitcast: {
427 llvm::report_fatal_error("Not yet implemented"); 457 UnimplementedError(Func->getContext()->getFlags());
428 break; 458 break;
429 } 459 }
430 } 460 }
431 } 461 }
432 462
433 void TargetARM32::lowerExtractElement(const InstExtractElement *Inst) { 463 void TargetARM32::lowerExtractElement(const InstExtractElement *Inst) {
434 (void)Inst; 464 (void)Inst;
435 llvm::report_fatal_error("Not yet implemented"); 465 UnimplementedError(Func->getContext()->getFlags());
436 } 466 }
437 467
438 void TargetARM32::lowerFcmp(const InstFcmp *Inst) { 468 void TargetARM32::lowerFcmp(const InstFcmp *Inst) {
439 (void)Inst; 469 (void)Inst;
440 llvm::report_fatal_error("Not yet implemented"); 470 UnimplementedError(Func->getContext()->getFlags());
441 } 471 }
442 472
443 void TargetARM32::lowerIcmp(const InstIcmp *Inst) { 473 void TargetARM32::lowerIcmp(const InstIcmp *Inst) {
444 (void)Inst; 474 (void)Inst;
445 llvm::report_fatal_error("Not yet implemented"); 475 UnimplementedError(Func->getContext()->getFlags());
446 } 476 }
447 477
448 void TargetARM32::lowerInsertElement(const InstInsertElement *Inst) { 478 void TargetARM32::lowerInsertElement(const InstInsertElement *Inst) {
449 (void)Inst; 479 (void)Inst;
450 llvm::report_fatal_error("Not yet implemented"); 480 UnimplementedError(Func->getContext()->getFlags());
451 } 481 }
452 482
453 void TargetARM32::lowerIntrinsicCall(const InstIntrinsicCall *Instr) { 483 void TargetARM32::lowerIntrinsicCall(const InstIntrinsicCall *Instr) {
454 switch (Intrinsics::IntrinsicID ID = Instr->getIntrinsicInfo().ID) { 484 switch (Intrinsics::IntrinsicID ID = Instr->getIntrinsicInfo().ID) {
455 case Intrinsics::AtomicCmpxchg: { 485 case Intrinsics::AtomicCmpxchg: {
456 llvm::report_fatal_error("Not yet implemented"); 486 UnimplementedError(Func->getContext()->getFlags());
457 return; 487 return;
458 } 488 }
459 case Intrinsics::AtomicFence: 489 case Intrinsics::AtomicFence:
460 llvm::report_fatal_error("Not yet implemented"); 490 UnimplementedError(Func->getContext()->getFlags());
461 return; 491 return;
462 case Intrinsics::AtomicFenceAll: 492 case Intrinsics::AtomicFenceAll:
463 // NOTE: FenceAll should prevent and load/store from being moved 493 // NOTE: FenceAll should prevent and load/store from being moved
464 // across the fence (both atomic and non-atomic). The InstARM32Mfence 494 // across the fence (both atomic and non-atomic). The InstARM32Mfence
465 // instruction is currently marked coarsely as "HasSideEffects". 495 // instruction is currently marked coarsely as "HasSideEffects".
466 llvm::report_fatal_error("Not yet implemented"); 496 UnimplementedError(Func->getContext()->getFlags());
467 return; 497 return;
468 case Intrinsics::AtomicIsLockFree: { 498 case Intrinsics::AtomicIsLockFree: {
469 llvm::report_fatal_error("Not yet implemented"); 499 UnimplementedError(Func->getContext()->getFlags());
470 return; 500 return;
471 } 501 }
472 case Intrinsics::AtomicLoad: { 502 case Intrinsics::AtomicLoad: {
473 llvm::report_fatal_error("Not yet implemented"); 503 UnimplementedError(Func->getContext()->getFlags());
474 return; 504 return;
475 } 505 }
476 case Intrinsics::AtomicRMW: 506 case Intrinsics::AtomicRMW:
477 llvm::report_fatal_error("Not yet implemented"); 507 UnimplementedError(Func->getContext()->getFlags());
478 return; 508 return;
479 case Intrinsics::AtomicStore: { 509 case Intrinsics::AtomicStore: {
480 llvm::report_fatal_error("Not yet implemented"); 510 UnimplementedError(Func->getContext()->getFlags());
481 return; 511 return;
482 } 512 }
483 case Intrinsics::Bswap: { 513 case Intrinsics::Bswap: {
484 llvm::report_fatal_error("Not yet implemented"); 514 UnimplementedError(Func->getContext()->getFlags());
485 return; 515 return;
486 } 516 }
487 case Intrinsics::Ctpop: { 517 case Intrinsics::Ctpop: {
488 llvm::report_fatal_error("Not yet implemented"); 518 UnimplementedError(Func->getContext()->getFlags());
489 return; 519 return;
490 } 520 }
491 case Intrinsics::Ctlz: { 521 case Intrinsics::Ctlz: {
492 llvm::report_fatal_error("Not yet implemented"); 522 UnimplementedError(Func->getContext()->getFlags());
493 return; 523 return;
494 } 524 }
495 case Intrinsics::Cttz: { 525 case Intrinsics::Cttz: {
496 llvm::report_fatal_error("Not yet implemented"); 526 UnimplementedError(Func->getContext()->getFlags());
497 return; 527 return;
498 } 528 }
499 case Intrinsics::Fabs: { 529 case Intrinsics::Fabs: {
500 llvm::report_fatal_error("Not yet implemented"); 530 UnimplementedError(Func->getContext()->getFlags());
501 return; 531 return;
502 } 532 }
503 case Intrinsics::Longjmp: { 533 case Intrinsics::Longjmp: {
504 InstCall *Call = makeHelperCall(H_call_longjmp, nullptr, 2); 534 InstCall *Call = makeHelperCall(H_call_longjmp, nullptr, 2);
505 Call->addArg(Instr->getArg(0)); 535 Call->addArg(Instr->getArg(0));
506 Call->addArg(Instr->getArg(1)); 536 Call->addArg(Instr->getArg(1));
507 lowerCall(Call); 537 lowerCall(Call);
508 return; 538 return;
509 } 539 }
510 case Intrinsics::Memcpy: { 540 case Intrinsics::Memcpy: {
(...skipping 24 matching lines...) Expand all
535 lowerCast(InstCast::create(Func, InstCast::Zext, ValExt, ValOp)); 565 lowerCast(InstCast::create(Func, InstCast::Zext, ValExt, ValOp));
536 InstCall *Call = makeHelperCall(H_call_memset, nullptr, 3); 566 InstCall *Call = makeHelperCall(H_call_memset, nullptr, 3);
537 Call->addArg(Instr->getArg(0)); 567 Call->addArg(Instr->getArg(0));
538 Call->addArg(ValExt); 568 Call->addArg(ValExt);
539 Call->addArg(Instr->getArg(2)); 569 Call->addArg(Instr->getArg(2));
540 lowerCall(Call); 570 lowerCall(Call);
541 return; 571 return;
542 } 572 }
543 case Intrinsics::NaClReadTP: { 573 case Intrinsics::NaClReadTP: {
544 if (Ctx->getFlags().getUseSandboxing()) { 574 if (Ctx->getFlags().getUseSandboxing()) {
545 llvm::report_fatal_error("Not yet implemented"); 575 UnimplementedError(Func->getContext()->getFlags());
546 } else { 576 } else {
547 InstCall *Call = makeHelperCall(H_call_read_tp, Instr->getDest(), 0); 577 InstCall *Call = makeHelperCall(H_call_read_tp, Instr->getDest(), 0);
548 lowerCall(Call); 578 lowerCall(Call);
549 } 579 }
550 return; 580 return;
551 } 581 }
552 case Intrinsics::Setjmp: { 582 case Intrinsics::Setjmp: {
553 InstCall *Call = makeHelperCall(H_call_setjmp, Instr->getDest(), 1); 583 InstCall *Call = makeHelperCall(H_call_setjmp, Instr->getDest(), 1);
554 Call->addArg(Instr->getArg(0)); 584 Call->addArg(Instr->getArg(0));
555 lowerCall(Call); 585 lowerCall(Call);
556 return; 586 return;
557 } 587 }
558 case Intrinsics::Sqrt: { 588 case Intrinsics::Sqrt: {
559 llvm::report_fatal_error("Not yet implemented"); 589 UnimplementedError(Func->getContext()->getFlags());
560 return; 590 return;
561 } 591 }
562 case Intrinsics::Stacksave: { 592 case Intrinsics::Stacksave: {
563 llvm::report_fatal_error("Not yet implemented"); 593 UnimplementedError(Func->getContext()->getFlags());
564 return; 594 return;
565 } 595 }
566 case Intrinsics::Stackrestore: { 596 case Intrinsics::Stackrestore: {
567 llvm::report_fatal_error("Not yet implemented"); 597 UnimplementedError(Func->getContext()->getFlags());
568 return; 598 return;
569 } 599 }
570 case Intrinsics::Trap: 600 case Intrinsics::Trap:
571 llvm::report_fatal_error("Not yet implemented"); 601 UnimplementedError(Func->getContext()->getFlags());
572 return; 602 return;
573 case Intrinsics::UnknownIntrinsic: 603 case Intrinsics::UnknownIntrinsic:
574 Func->setError("Should not be lowering UnknownIntrinsic"); 604 Func->setError("Should not be lowering UnknownIntrinsic");
575 return; 605 return;
576 } 606 }
577 return; 607 return;
578 } 608 }
579 609
580 void TargetARM32::lowerLoad(const InstLoad *Inst) { 610 void TargetARM32::lowerLoad(const InstLoad *Inst) {
581 (void)Inst; 611 (void)Inst;
582 llvm::report_fatal_error("Not yet implemented"); 612 UnimplementedError(Func->getContext()->getFlags());
583 } 613 }
584 614
585 void TargetARM32::doAddressOptLoad() { 615 void TargetARM32::doAddressOptLoad() {
586 llvm::report_fatal_error("Not yet implemented"); 616 UnimplementedError(Func->getContext()->getFlags());
587 } 617 }
588 618
589 void TargetARM32::randomlyInsertNop(float Probability) { 619 void TargetARM32::randomlyInsertNop(float Probability) {
590 RandomNumberGeneratorWrapper RNG(Ctx->getRNG()); 620 RandomNumberGeneratorWrapper RNG(Ctx->getRNG());
591 if (RNG.getTrueWithProbability(Probability)) { 621 if (RNG.getTrueWithProbability(Probability)) {
592 llvm::report_fatal_error("Not yet implemented"); 622 UnimplementedError(Func->getContext()->getFlags());
593 } 623 }
594 } 624 }
595 625
596 void TargetARM32::lowerPhi(const InstPhi * /*Inst*/) { 626 void TargetARM32::lowerPhi(const InstPhi * /*Inst*/) {
597 Func->setError("Phi found in regular instruction list"); 627 Func->setError("Phi found in regular instruction list");
598 } 628 }
599 629
600 void TargetARM32::lowerRet(const InstRet *Inst) { 630 void TargetARM32::lowerRet(const InstRet *Inst) {
601 (void)Inst; 631 Variable *Reg = nullptr;
602 llvm::report_fatal_error("Not yet implemented"); 632 if (Inst->hasRetValue()) {
633 UnimplementedError(Func->getContext()->getFlags());
634 }
635 // Add a ret instruction even if sandboxing is enabled, because
636 // addEpilog explicitly looks for a ret instruction as a marker for
637 // where to insert the frame removal instructions.
638 // addEpilog is responsible for restoring the "lr" register as needed
639 // prior to this ret instruction.
640 _ret(getPhysicalRegister(RegARM32::Reg_lr), Reg);
641 // Add a fake use of sp to make sure sp stays alive for the entire
642 // function. Otherwise post-call sp adjustments get dead-code
643 // eliminated. TODO: Are there more places where the fake use
644 // should be inserted? E.g. "void f(int n){while(1) g(n);}" may not
645 // have a ret instruction.
646 Variable *sp = Func->getTarget()->getPhysicalRegister(RegARM32::Reg_sp);
647 Context.insert(InstFakeUse::create(Func, sp));
603 } 648 }
604 649
605 void TargetARM32::lowerSelect(const InstSelect *Inst) { 650 void TargetARM32::lowerSelect(const InstSelect *Inst) {
606 (void)Inst; 651 (void)Inst;
607 llvm::report_fatal_error("Not yet implemented"); 652 UnimplementedError(Func->getContext()->getFlags());
608 } 653 }
609 654
610 void TargetARM32::lowerStore(const InstStore *Inst) { 655 void TargetARM32::lowerStore(const InstStore *Inst) {
611 (void)Inst; 656 (void)Inst;
612 llvm::report_fatal_error("Not yet implemented"); 657 UnimplementedError(Func->getContext()->getFlags());
613 } 658 }
614 659
615 void TargetARM32::doAddressOptStore() { 660 void TargetARM32::doAddressOptStore() {
616 llvm::report_fatal_error("Not yet implemented"); 661 UnimplementedError(Func->getContext()->getFlags());
617 } 662 }
618 663
619 void TargetARM32::lowerSwitch(const InstSwitch *Inst) { 664 void TargetARM32::lowerSwitch(const InstSwitch *Inst) {
620 (void)Inst; 665 (void)Inst;
621 llvm::report_fatal_error("Not yet implemented"); 666 UnimplementedError(Func->getContext()->getFlags());
622 } 667 }
623 668
624 void TargetARM32::lowerUnreachable(const InstUnreachable * /*Inst*/) { 669 void TargetARM32::lowerUnreachable(const InstUnreachable * /*Inst*/) {
625 llvm_unreachable("Not yet implemented"); 670 llvm_unreachable("Not yet implemented");
626 } 671 }
627 672
628 // Turn an i64 Phi instruction into a pair of i32 Phi instructions, to 673 // Turn an i64 Phi instruction into a pair of i32 Phi instructions, to
629 // preserve integrity of liveness analysis. Undef values are also 674 // preserve integrity of liveness analysis. Undef values are also
630 // turned into zeroes, since loOperand() and hiOperand() don't expect 675 // turned into zeroes, since loOperand() and hiOperand() don't expect
631 // Undef input. 676 // Undef input.
632 void TargetARM32::prelowerPhis() { 677 void TargetARM32::prelowerPhis() {
633 llvm::report_fatal_error("Not yet implemented"); 678 UnimplementedError(Func->getContext()->getFlags());
634 } 679 }
635 680
636 // Lower the pre-ordered list of assignments into mov instructions. 681 // Lower the pre-ordered list of assignments into mov instructions.
637 // Also has to do some ad-hoc register allocation as necessary. 682 // Also has to do some ad-hoc register allocation as necessary.
638 void TargetARM32::lowerPhiAssignments(CfgNode *Node, 683 void TargetARM32::lowerPhiAssignments(CfgNode *Node,
639 const AssignList &Assignments) { 684 const AssignList &Assignments) {
640 (void)Node; 685 (void)Node;
641 (void)Assignments; 686 (void)Assignments;
642 llvm::report_fatal_error("Not yet implemented"); 687 UnimplementedError(Func->getContext()->getFlags());
643 } 688 }
644 689
645 void TargetARM32::postLower() { 690 void TargetARM32::postLower() {
646 if (Ctx->getFlags().getOptLevel() == Opt_m1) 691 if (Ctx->getFlags().getOptLevel() == Opt_m1)
647 return; 692 return;
648 // Find two-address non-SSA instructions where Dest==Src0, and set 693 // Find two-address non-SSA instructions where Dest==Src0, and set
649 // the DestNonKillable flag to keep liveness analysis consistent. 694 // the DestNonKillable flag to keep liveness analysis consistent.
650 llvm::report_fatal_error("Not yet implemented"); 695 UnimplementedError(Func->getContext()->getFlags());
651 } 696 }
652 697
653 void TargetARM32::makeRandomRegisterPermutation( 698 void TargetARM32::makeRandomRegisterPermutation(
654 llvm::SmallVectorImpl<int32_t> &Permutation, 699 llvm::SmallVectorImpl<int32_t> &Permutation,
655 const llvm::SmallBitVector &ExcludeRegisters) const { 700 const llvm::SmallBitVector &ExcludeRegisters) const {
656 (void)Permutation; 701 (void)Permutation;
657 (void)ExcludeRegisters; 702 (void)ExcludeRegisters;
658 llvm::report_fatal_error("Not yet implemented"); 703 UnimplementedError(Func->getContext()->getFlags());
659 } 704 }
660 705
661 /* TODO(jvoung): avoid duplicate symbols with multiple targets. 706 /* TODO(jvoung): avoid duplicate symbols with multiple targets.
662 void ConstantUndef::emitWithoutDollar(GlobalContext *) const { 707 void ConstantUndef::emitWithoutDollar(GlobalContext *) const {
663 llvm_unreachable("Not expecting to emitWithoutDollar undef"); 708 llvm_unreachable("Not expecting to emitWithoutDollar undef");
664 } 709 }
665 710
666 void ConstantUndef::emit(GlobalContext *) const { 711 void ConstantUndef::emit(GlobalContext *) const {
667 llvm_unreachable("undef value encountered by emitter."); 712 llvm_unreachable("undef value encountered by emitter.");
668 } 713 }
669 */ 714 */
670 715
671 TargetDataARM32::TargetDataARM32(GlobalContext *Ctx) 716 TargetDataARM32::TargetDataARM32(GlobalContext *Ctx)
672 : TargetDataLowering(Ctx) {} 717 : TargetDataLowering(Ctx) {}
673 718
674 void TargetDataARM32::lowerGlobal(const VariableDeclaration &Var) const { 719 void TargetDataARM32::lowerGlobal(const VariableDeclaration &Var) const {
675 (void)Var; 720 (void)Var;
676 llvm::report_fatal_error("Not yet implemented"); 721 UnimplementedError(Ctx->getFlags());
677 } 722 }
678 723
679 void TargetDataARM32::lowerGlobals( 724 void TargetDataARM32::lowerGlobals(
680 std::unique_ptr<VariableDeclarationList> Vars) const { 725 std::unique_ptr<VariableDeclarationList> Vars) const {
681 switch (Ctx->getFlags().getOutFileType()) { 726 switch (Ctx->getFlags().getOutFileType()) {
682 case FT_Elf: { 727 case FT_Elf: {
683 ELFObjectWriter *Writer = Ctx->getObjectWriter(); 728 ELFObjectWriter *Writer = Ctx->getObjectWriter();
684 Writer->writeDataSection(*Vars, llvm::ELF::R_ARM_ABS32); 729 Writer->writeDataSection(*Vars, llvm::ELF::R_ARM_ABS32);
685 } break; 730 } break;
686 case FT_Asm: 731 case FT_Asm:
687 case FT_Iasm: { 732 case FT_Iasm: {
688 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly(); 733 const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly();
689 OstreamLocker L(Ctx); 734 OstreamLocker L(Ctx);
690 for (const VariableDeclaration *Var : *Vars) { 735 for (const VariableDeclaration *Var : *Vars) {
691 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { 736 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) {
692 lowerGlobal(*Var); 737 lowerGlobal(*Var);
693 } 738 }
694 } 739 }
695 } break; 740 } break;
696 } 741 }
697 } 742 }
698 743
699 void TargetDataARM32::lowerConstants() const { 744 void TargetDataARM32::lowerConstants() const {
700 if (Ctx->getFlags().getDisableTranslation()) 745 if (Ctx->getFlags().getDisableTranslation())
701 return; 746 return;
702 llvm::report_fatal_error("Not yet implemented"); 747 UnimplementedError(Ctx->getFlags());
703 } 748 }
704 749
705 } // end of namespace Ice 750 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698