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