OLD | NEW |
1 //===- subzero/src/IceConverter.cpp - Converts LLVM to Ice ---------------===// | 1 //===- subzero/src/IceConverter.cpp - Converts LLVM to Ice ---------------===// |
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 LLVM to ICE converter. | 10 // This file implements the LLVM to ICE converter. |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 case Instruction::FDiv: | 330 case Instruction::FDiv: |
331 return convertArithInstruction(Inst, Ice::InstArithmetic::Fdiv); | 331 return convertArithInstruction(Inst, Ice::InstArithmetic::Fdiv); |
332 case Instruction::FRem: | 332 case Instruction::FRem: |
333 return convertArithInstruction(Inst, Ice::InstArithmetic::Frem); | 333 return convertArithInstruction(Inst, Ice::InstArithmetic::Frem); |
334 case Instruction::And: | 334 case Instruction::And: |
335 return convertArithInstruction(Inst, Ice::InstArithmetic::And); | 335 return convertArithInstruction(Inst, Ice::InstArithmetic::And); |
336 case Instruction::Or: | 336 case Instruction::Or: |
337 return convertArithInstruction(Inst, Ice::InstArithmetic::Or); | 337 return convertArithInstruction(Inst, Ice::InstArithmetic::Or); |
338 case Instruction::Xor: | 338 case Instruction::Xor: |
339 return convertArithInstruction(Inst, Ice::InstArithmetic::Xor); | 339 return convertArithInstruction(Inst, Ice::InstArithmetic::Xor); |
| 340 case Instruction::ExtractElement: |
| 341 return convertExtractElementInstruction(cast<ExtractElementInst>(Inst)); |
| 342 case Instruction::InsertElement: |
| 343 return convertInsertElementInstruction(cast<InsertElementInst>(Inst)); |
340 case Instruction::Call: | 344 case Instruction::Call: |
341 return convertCallInstruction(cast<CallInst>(Inst)); | 345 return convertCallInstruction(cast<CallInst>(Inst)); |
342 case Instruction::Alloca: | 346 case Instruction::Alloca: |
343 return convertAllocaInstruction(cast<AllocaInst>(Inst)); | 347 return convertAllocaInstruction(cast<AllocaInst>(Inst)); |
344 case Instruction::Unreachable: | 348 case Instruction::Unreachable: |
345 return convertUnreachableInstruction(cast<UnreachableInst>(Inst)); | 349 return convertUnreachableInstruction(cast<UnreachableInst>(Inst)); |
346 default: | 350 default: |
347 report_fatal_error(std::string("Invalid PNaCl instruction: ") + | 351 report_fatal_error(std::string("Invalid PNaCl instruction: ") + |
348 LLVMObjectAsString(Inst)); | 352 LLVMObjectAsString(Inst)); |
349 } | 353 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 Cond = Ice::InstFcmp::Uno; | 531 Cond = Ice::InstFcmp::Uno; |
528 break; | 532 break; |
529 case CmpInst::FCMP_TRUE: | 533 case CmpInst::FCMP_TRUE: |
530 Cond = Ice::InstFcmp::True; | 534 Cond = Ice::InstFcmp::True; |
531 break; | 535 break; |
532 } | 536 } |
533 | 537 |
534 return Ice::InstFcmp::create(Func, Cond, Dest, Src0, Src1); | 538 return Ice::InstFcmp::create(Func, Cond, Dest, Src0, Src1); |
535 } | 539 } |
536 | 540 |
| 541 Ice::Inst *convertExtractElementInstruction(const ExtractElementInst *Inst) { |
| 542 Ice::Variable *Dest = mapValueToIceVar(Inst); |
| 543 Ice::Operand *Source1 = convertValue(Inst->getOperand(0)); |
| 544 Ice::Operand *Source2 = convertValue(Inst->getOperand(1)); |
| 545 return Ice::InstExtractElement::create(Func, Dest, Source1, Source2); |
| 546 } |
| 547 |
| 548 Ice::Inst *convertInsertElementInstruction(const InsertElementInst *Inst) { |
| 549 Ice::Variable *Dest = mapValueToIceVar(Inst); |
| 550 Ice::Operand *Source1 = convertValue(Inst->getOperand(0)); |
| 551 Ice::Operand *Source2 = convertValue(Inst->getOperand(1)); |
| 552 Ice::Operand *Source3 = convertValue(Inst->getOperand(2)); |
| 553 return Ice::InstInsertElement::create(Func, Dest, Source1, Source2, |
| 554 Source3); |
| 555 } |
| 556 |
537 Ice::Inst *convertSelectInstruction(const SelectInst *Inst) { | 557 Ice::Inst *convertSelectInstruction(const SelectInst *Inst) { |
538 Ice::Variable *Dest = mapValueToIceVar(Inst); | 558 Ice::Variable *Dest = mapValueToIceVar(Inst); |
539 Ice::Operand *Cond = convertValue(Inst->getCondition()); | 559 Ice::Operand *Cond = convertValue(Inst->getCondition()); |
540 Ice::Operand *Source1 = convertValue(Inst->getTrueValue()); | 560 Ice::Operand *Source1 = convertValue(Inst->getTrueValue()); |
541 Ice::Operand *Source2 = convertValue(Inst->getFalseValue()); | 561 Ice::Operand *Source2 = convertValue(Inst->getFalseValue()); |
542 return Ice::InstSelect::create(Func, Dest, Cond, Source1, Source2); | 562 return Ice::InstSelect::create(Func, Dest, Cond, Source1, Source2); |
543 } | 563 } |
544 | 564 |
545 Ice::Inst *convertSwitchInstruction(const SwitchInst *Inst) { | 565 Ice::Inst *convertSwitchInstruction(const SwitchInst *Inst) { |
546 Ice::Operand *Source = convertValue(Inst->getCondition()); | 566 Ice::Operand *Source = convertValue(Inst->getCondition()); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() | 740 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec() |
721 << " sec\n"; | 741 << " sec\n"; |
722 } | 742 } |
723 translateFcn(Fcn); | 743 translateFcn(Fcn); |
724 } | 744 } |
725 | 745 |
726 emitConstants(); | 746 emitConstants(); |
727 } | 747 } |
728 | 748 |
729 } // end of Ice namespace. | 749 } // end of Ice namespace. |
OLD | NEW |