mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-11-03 14:21:30 +00:00 
			
		
		
		
	Instead of hacking in custom support for Invoke/Unwind, use the LowerInvoke pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8871 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		@@ -131,8 +131,6 @@ namespace {
 | 
				
			|||||||
    void doCall(const ValueRecord &Ret, MachineInstr *CallMI,
 | 
					    void doCall(const ValueRecord &Ret, MachineInstr *CallMI,
 | 
				
			||||||
		const std::vector<ValueRecord> &Args);
 | 
							const std::vector<ValueRecord> &Args);
 | 
				
			||||||
    void visitCallInst(CallInst &I);
 | 
					    void visitCallInst(CallInst &I);
 | 
				
			||||||
    void visitInvokeInst(InvokeInst &II);
 | 
					 | 
				
			||||||
    void visitUnwindInst(UnwindInst &UI);
 | 
					 | 
				
			||||||
    void visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &I);
 | 
					    void visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &I);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Arithmetic operators
 | 
					    // Arithmetic operators
 | 
				
			||||||
@@ -997,35 +995,6 @@ void ISel::visitCallInst(CallInst &CI) {
 | 
				
			|||||||
}	 
 | 
					}	 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// visitInvokeInst - For now, we don't support the llvm.unwind intrinsic, so
 | 
					 | 
				
			||||||
// invoke's are just calls with an unconditional branch after them!
 | 
					 | 
				
			||||||
void ISel::visitInvokeInst(InvokeInst &II) {
 | 
					 | 
				
			||||||
  MachineInstr *TheCall;
 | 
					 | 
				
			||||||
  if (Function *F = II.getCalledFunction()) {
 | 
					 | 
				
			||||||
    // Emit a CALL instruction with PC-relative displacement.
 | 
					 | 
				
			||||||
    TheCall = BuildMI(X86::CALLpcrel32, 1).addGlobalAddress(F, true);
 | 
					 | 
				
			||||||
  } else {  // Emit an indirect call...
 | 
					 | 
				
			||||||
    unsigned Reg = getReg(II.getCalledValue());
 | 
					 | 
				
			||||||
    TheCall = BuildMI(X86::CALLr32, 1).addReg(Reg);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<ValueRecord> Args;
 | 
					 | 
				
			||||||
  for (unsigned i = 3, e = II.getNumOperands(); i != e; ++i)
 | 
					 | 
				
			||||||
    Args.push_back(ValueRecord(II.getOperand(i)));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  unsigned DestReg = II.getType() != Type::VoidTy ? getReg(II) : 0;
 | 
					 | 
				
			||||||
  doCall(ValueRecord(DestReg, II.getType()), TheCall, Args);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // If the normal destination is not the next basic block, emit a 'jmp'.
 | 
					 | 
				
			||||||
  if (II.getNormalDest() != getBlockAfter(II.getParent()))
 | 
					 | 
				
			||||||
    BuildMI(BB, X86::JMP, 1).addPCDisp(II.getNormalDest());
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ISel::visitUnwindInst(UnwindInst &UI) {
 | 
					 | 
				
			||||||
  // unwind is not supported yet!  Just abort when the unwind inst is executed!
 | 
					 | 
				
			||||||
  BuildMI(BB, X86::CALLpcrel32, 1).addExternalSymbol("abort", true); 
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ISel::visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &CI) {
 | 
					void ISel::visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &CI) {
 | 
				
			||||||
  unsigned TmpReg1, TmpReg2;
 | 
					  unsigned TmpReg1, TmpReg2;
 | 
				
			||||||
  switch (ID) {
 | 
					  switch (ID) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -131,8 +131,6 @@ namespace {
 | 
				
			|||||||
    void doCall(const ValueRecord &Ret, MachineInstr *CallMI,
 | 
					    void doCall(const ValueRecord &Ret, MachineInstr *CallMI,
 | 
				
			||||||
		const std::vector<ValueRecord> &Args);
 | 
							const std::vector<ValueRecord> &Args);
 | 
				
			||||||
    void visitCallInst(CallInst &I);
 | 
					    void visitCallInst(CallInst &I);
 | 
				
			||||||
    void visitInvokeInst(InvokeInst &II);
 | 
					 | 
				
			||||||
    void visitUnwindInst(UnwindInst &UI);
 | 
					 | 
				
			||||||
    void visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &I);
 | 
					    void visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &I);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Arithmetic operators
 | 
					    // Arithmetic operators
 | 
				
			||||||
@@ -997,35 +995,6 @@ void ISel::visitCallInst(CallInst &CI) {
 | 
				
			|||||||
}	 
 | 
					}	 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// visitInvokeInst - For now, we don't support the llvm.unwind intrinsic, so
 | 
					 | 
				
			||||||
// invoke's are just calls with an unconditional branch after them!
 | 
					 | 
				
			||||||
void ISel::visitInvokeInst(InvokeInst &II) {
 | 
					 | 
				
			||||||
  MachineInstr *TheCall;
 | 
					 | 
				
			||||||
  if (Function *F = II.getCalledFunction()) {
 | 
					 | 
				
			||||||
    // Emit a CALL instruction with PC-relative displacement.
 | 
					 | 
				
			||||||
    TheCall = BuildMI(X86::CALLpcrel32, 1).addGlobalAddress(F, true);
 | 
					 | 
				
			||||||
  } else {  // Emit an indirect call...
 | 
					 | 
				
			||||||
    unsigned Reg = getReg(II.getCalledValue());
 | 
					 | 
				
			||||||
    TheCall = BuildMI(X86::CALLr32, 1).addReg(Reg);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<ValueRecord> Args;
 | 
					 | 
				
			||||||
  for (unsigned i = 3, e = II.getNumOperands(); i != e; ++i)
 | 
					 | 
				
			||||||
    Args.push_back(ValueRecord(II.getOperand(i)));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  unsigned DestReg = II.getType() != Type::VoidTy ? getReg(II) : 0;
 | 
					 | 
				
			||||||
  doCall(ValueRecord(DestReg, II.getType()), TheCall, Args);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // If the normal destination is not the next basic block, emit a 'jmp'.
 | 
					 | 
				
			||||||
  if (II.getNormalDest() != getBlockAfter(II.getParent()))
 | 
					 | 
				
			||||||
    BuildMI(BB, X86::JMP, 1).addPCDisp(II.getNormalDest());
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ISel::visitUnwindInst(UnwindInst &UI) {
 | 
					 | 
				
			||||||
  // unwind is not supported yet!  Just abort when the unwind inst is executed!
 | 
					 | 
				
			||||||
  BuildMI(BB, X86::CALLpcrel32, 1).addExternalSymbol("abort", true); 
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ISel::visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &CI) {
 | 
					void ISel::visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &CI) {
 | 
				
			||||||
  unsigned TmpReg1, TmpReg2;
 | 
					  unsigned TmpReg1, TmpReg2;
 | 
				
			||||||
  switch (ID) {
 | 
					  switch (ID) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,6 +50,13 @@ bool X86TargetMachine::addPassesToEmitAssembly(PassManager &PM,
 | 
				
			|||||||
  // FIXME: Implement the switch instruction in the instruction selector!
 | 
					  // FIXME: Implement the switch instruction in the instruction selector!
 | 
				
			||||||
  PM.add(createLowerSwitchPass());
 | 
					  PM.add(createLowerSwitchPass());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // FIXME: Implement the invoke/unwind instructions!
 | 
				
			||||||
 | 
					  PM.add(createLowerInvokePass());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // FIXME: The code generator does not properly handle functions with
 | 
				
			||||||
 | 
					  // unreachable basic blocks.
 | 
				
			||||||
 | 
					  PM.add(createCFGSimplificationPass());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (NoPatternISel)
 | 
					  if (NoPatternISel)
 | 
				
			||||||
    PM.add(createX86SimpleInstructionSelector(*this));
 | 
					    PM.add(createX86SimpleInstructionSelector(*this));
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
@@ -94,6 +101,13 @@ bool X86TargetMachine::addPassesToJITCompile(FunctionPassManager &PM) {
 | 
				
			|||||||
  // FIXME: Implement the switch instruction in the instruction selector!
 | 
					  // FIXME: Implement the switch instruction in the instruction selector!
 | 
				
			||||||
  PM.add(createLowerSwitchPass());
 | 
					  PM.add(createLowerSwitchPass());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // FIXME: Implement the invoke/unwind instructions!
 | 
				
			||||||
 | 
					  PM.add(createLowerInvokePass());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // FIXME: The code generator does not properly handle functions with
 | 
				
			||||||
 | 
					  // unreachable basic blocks.
 | 
				
			||||||
 | 
					  PM.add(createCFGSimplificationPass());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (NoPatternISel)
 | 
					  if (NoPatternISel)
 | 
				
			||||||
    PM.add(createX86SimpleInstructionSelector(*this));
 | 
					    PM.add(createX86SimpleInstructionSelector(*this));
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user