[LLVMdev] Trouble implementing a new subtarget for X86

Amogh Akshintala aakshintala at cs.stonybrook.edu
Sat Jan 19 20:12:55 PST 2013


Hey all,
I am trying to implement a new subtarget for the X86 target that has 
only 64 bit registers and instructions and a very minimal ISA excluding 
any FPU instructions etc.

I have made the required changes to the instructions such that all the 
instructions that I don't wish to use have a required<> clause that 
precludes them from being utilised when compiling for this subtarget. I 
have modified the X86TargetLowering constructor to only include the GR64 
group of registers for this particular subtarget.

I am now faced with issues with the Lowering of Formal targets. I have 
implemented a new calling convention that changes all arguments of type 
i8, i16 or i32 to i64 and only uses the 64 bit registers to pass 
arguments. I am however encountering an error in the 
FormalArgumentLowering function in x86ISelLowering.cpp. I have 
reproduced the error and Debug output in the attached file. The code 
being compiled is a simple 2 function program where main calls a 
function and that function counts to 'n' the parameter passed to it from 
main.

Can anyone help me figure out why the formal arguments suddenly have no 
EVT value?(that is the code that fails) at line 1979 of X86ISelLowering.cpp

Thanks a lot for your time,
Amogh

-- 
The Wheel of Time turns and Ages come and go, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth returns again.

-------------- next part --------------
llc -march=x86 -mcpu=CSE502 -filetype=asm -view-legalize-dags -debug blah.s
Args: llc -march=x86 -mcpu=CSE502 -filetype=asm -view-legalize-dags -debug blah.s 

Features:
CPU:CSE502

Subtarget features: SSELevel 0, 3DNowLevel 0, 64bit 1
MERGING MOSTLY EMPTY BLOCKS - BEFORE:

for.body:                                         ; preds = %for.cond
  br label %for.inc

for.inc:                                          ; preds = %for.body
  %2 = load i32* %i, align 4
  %inc = add nsw i32 %2, 1
  store i32 %inc, i32* %i, align 4
  br label %for.cond
AFTER:

for.inc:                                          ; preds = %for.cond
  %2 = load i32* %i, align 4
  %inc = add nsw i32 %2, 1
  store i32 %inc, i32* %i, align 4
  br label %for.cond



CGP: Found      local addrmode: [Base:%n.addr]
CGP: Found      local addrmode: [Base:%i]
CGP: Found      local addrmode: [Base:%i]
CGP: Found      local addrmode: [Base:%n.addr]
CGP: Found      local addrmode: [Base:%i]
CGP: Found      local addrmode: [Base:%i]
Computing probabilities for for.inc
set edge for.inc -> 0 successor weight to 124
Computing probabilities for for.end
Computing probabilities for for.cond
set edge for.cond -> 0 successor weight to 124
set edge for.cond -> 1 successor weight to 4
Computing probabilities for entry



=== countto
Unknown argument type!
UNREACHABLE executed at /home/theusurper/llvm/llvm/lib/Target/X86/X86ISelLowering.cpp:1979!
0  llc             0x000000000141a8ae
1  llc             0x000000000141adaa
2  libpthread.so.0 0x00007fd9c91e6cb0
3  libc.so.6       0x00007fd9c822d425 gsignal + 53
4  libc.so.6       0x00007fd9c8230b8b abort + 379
5  llc             0x0000000001400c86
6  llc             0x0000000000aaac92 llvm::X86TargetLowering::LowerFormalArguments(llvm::SDValue, llvm::CallingConv::ID, bool, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::DebugLoc, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&) const + 1378
7  llc             0x0000000000c75883 llvm::SelectionDAGISel::LowerArguments(llvm::BasicBlock const*) + 2339
8  llc             0x0000000000c9af15 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 949
9  llc             0x0000000000c99e95 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 853
10 llc             0x0000000000e9238e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 110
11 llc             0x0000000001395ddf llvm::FPPassManager::runOnFunction(llvm::Function&) + 431
12 llc             0x00000000013960c8 llvm::FPPassManager::runOnModule(llvm::Module&) + 104
13 llc             0x00000000013964ca llvm::MPPassManager::runOnModule(llvm::Module&) + 634
14 llc             0x0000000001396c7e llvm::PassManagerImpl::run(llvm::Module&) + 302
15 llc             0x0000000001396ed1 llvm::PassManager::run(llvm::Module&) + 33
16 llc             0x00000000005fba55
17 llc             0x00000000005fa712 main + 226
18 libc.so.6       0x00007fd9c821876d __libc_start_main + 237
19 llc             0x00000000005fa555
Stack dump:
0.	Program arguments: llc -march=x86 -mcpu=CSE502 -filetype=asm -view-legalize-dags -debug blah.s 
1.	Running pass 'Function Pass Manager' on module 'blah.s'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@countto'
Aborted (core dumped)



More information about the llvm-dev mailing list