Banksel immediate constant will always immediately follow the GA/ES, so scan an insn from beginnin to find out the banksel operand.
llvm-svn: 69883
This commit is contained in:
		
							parent
							
								
									f0a8344bac
								
							
						
					
					
						commit
						5058f240d9
					
				| 
						 | 
					@ -48,26 +48,28 @@ bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
 | 
				
			||||||
  std::string NewBank = "";
 | 
					  std::string NewBank = "";
 | 
				
			||||||
  unsigned Operands = MI->getNumOperands();
 | 
					  unsigned Operands = MI->getNumOperands();
 | 
				
			||||||
  if (Operands > 1) {
 | 
					  if (Operands > 1) {
 | 
				
			||||||
    // Global address or external symbol should be second operand from last
 | 
					    // If we have a Global address or external symbol then we need to print 
 | 
				
			||||||
    // if we want to print banksel for it.
 | 
					    // banksel for it. 
 | 
				
			||||||
    unsigned BankSelVar = Operands - 2;
 | 
					    unsigned BankSelVar = 0;
 | 
				
			||||||
    // In cases where an instruction has a def or use defined in td file,
 | 
					    MachineOperand Op = MI->getOperand(BankSelVar);
 | 
				
			||||||
    // that def or use becomes a machine instruction operand.
 | 
					    while (BankSelVar < Operands-1) {
 | 
				
			||||||
    // eg. addfw_1 instruction defines STATUS register. So the machine
 | 
					      Op = MI->getOperand(BankSelVar);
 | 
				
			||||||
    // instruction for it has MO_Register Operand as its last operand.
 | 
					      if ((Op.getType() ==  MachineOperand::MO_GlobalAddress) ||
 | 
				
			||||||
    while ((MI->getOperand(BankSelVar + 1).getType() ==
 | 
					          (Op.getType() ==  MachineOperand::MO_ExternalSymbol))
 | 
				
			||||||
           MachineOperand::MO_Register) && (BankSelVar > 0))
 | 
					        break;
 | 
				
			||||||
     BankSelVar--;
 | 
					      BankSelVar++;
 | 
				
			||||||
    const MachineOperand &Op = MI->getOperand(BankSelVar);
 | 
					    }
 | 
				
			||||||
 | 
					    if (BankSelVar < Operands-1) {
 | 
				
			||||||
      unsigned OpType = Op.getType();
 | 
					      unsigned OpType = Op.getType();
 | 
				
			||||||
    if (OpType == MachineOperand::MO_GlobalAddress ||
 | 
					 | 
				
			||||||
        OpType == MachineOperand::MO_ExternalSymbol) {
 | 
					 | 
				
			||||||
      if (OpType == MachineOperand::MO_GlobalAddress ) 
 | 
					      if (OpType == MachineOperand::MO_GlobalAddress ) 
 | 
				
			||||||
        NewBank = Op.getGlobal()->getSection(); 
 | 
					        NewBank = Op.getGlobal()->getSection(); 
 | 
				
			||||||
      else {
 | 
					      else {
 | 
				
			||||||
        // External Symbol is generated for temp data. Temp data in in
 | 
					        // External Symbol is generated for temp data and arguments. They are 
 | 
				
			||||||
        // fdata.<functionname>.# section.
 | 
					        // in fpdata.<functionname>.# section.
 | 
				
			||||||
        NewBank = "fpdata." + CurrentFnName +".#";
 | 
					        std::string ESName = Op.getSymbolName();
 | 
				
			||||||
 | 
					        int index = ESName.find_first_of(".");
 | 
				
			||||||
 | 
					        std::string FnName = ESName.substr(0,index);
 | 
				
			||||||
 | 
					        NewBank = "fpdata." + FnName +".#";
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      // Operand after global address or external symbol should be  banksel.
 | 
					      // Operand after global address or external symbol should be  banksel.
 | 
				
			||||||
      // Value 1 for this operand means we need to generate banksel else do not
 | 
					      // Value 1 for this operand means we need to generate banksel else do not
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue