There should be a definition of GPR8RegClassID in $build_dir/lib/Target/AVR/AVRGenRegisterInfo.inc which should be included by AVRRegisterInfo.h. AArch64 includes its AArch64RegisterInfo.h in AArch64InstructionSelector.cpp but it seems that ARM gets it indirectly when it includes ARMSubtarget.h. It looks like you need to add '#include "AVRRegisterInfo.h"' to AVRInstructionSelector.h.
There should be a definition of GPR8RegClassID in $build_dir/lib/Target/AVR/AVRGenRegisterInfo.inc which should be included by AVRRegisterInfo.h. AArch64 includes its AArch64RegisterInfo.h in AArch64InstructionSelector.cpp but it seems that ARM gets it indirectly when it includes ARMSubtarget.h. It looks like you need to add '#include "AVRRegisterInfo.h"' to AVRInstructionSelector.h.
Sorry, I've given you the wrong header. The one I gave you does include AVRGenRegisterInfo.inc but doesn't define the enum because it uses the wrong macros for that. The correct one is '#include "MCTargetDesc/AVRMCTargetDesc.h"'. You'll also need to 'include "AVRRegisterBanks.td"' somewhere in your .td files. At the moment, your register banks definitions aren't being used.
I only implemented the skeleton of GlobalISel, removed ARM related code further, it needs to override several functions to make AVR NEW instruction selector to really work.
In file included from /data/project/xiangzhai/llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp:97:
/data/project/xiangzhai/llvm/build/lib/Target/RISCV/RISCVGenGlobalISel.inc:100:7: error: use of
undeclared identifier 'Subtarget'
if (Subtarget->is64Bit())
^
Even if no errors after comment `if (Subtarget->is64Bit())` in RISCVInstrInfo.td, but it is monkey patch, and it can't handle riscv64 without the if condition check.
In file included from
/data/project/xiangzhai/llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp:97:
/data/project/xiangzhai/llvm/build/lib/Target/RISCV/RISCVGenGlobalISel.inc:100:7:
error: use of
undeclared identifier 'Subtarget'
if (Subtarget->is64Bit())
^
Even if no errors after comment `if (Subtarget->is64Bit())` in
RISCVInstrInfo.td, but it is monkey patch, and it can't handle riscv64
without the if condition check.
I haven't looked into this, but I would imagine that none of the
patterns using that are supported yet, and that's why we don't see any
errors for ARM yet.
How ARM handle this? and I removed all ARM related code in RISCVXXX.cpp,
only keep skeleton for easy debug, please give me some hint, thanks a lot!
ARMInstructionSelector has an ARMSubtarget reference called STI. We'll
probably have to rename that to Subtarget to support something like
this in the future.
What you need to do when you run into this kind of error is to add the
relevant members to your InstructionSelector. Each target may make
slightly different assumptions about what exists in the
InstructionSelector. This one is pretty obvious from the name, but in
the general case you might have to look at what exists in DAGISel.
In file included from
/data/project/xiangzhai/llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp:97:
/data/project/xiangzhai/llvm/build/lib/Target/RISCV/RISCVGenGlobalISel.inc:100:7:
error: use of
undeclared identifier 'Subtarget'
if (Subtarget->is64Bit())
^
Even if no errors after comment `if (Subtarget->is64Bit())` in
RISCVInstrInfo.td, but it is monkey patch, and it can't handle riscv64
without the if condition check.
I haven't looked into this, but I would imagine that none of the
patterns using that are supported yet, and that's why we don't see any
errors for ARM yet.
How ARM handle this? and I removed all ARM related code in RISCVXXX.cpp,
only keep skeleton for easy debug, please give me some hint, thanks a lot!
ARMInstructionSelector has an ARMSubtarget reference called STI. We'll
probably have to rename that to Subtarget to support something like
this in the future.
What you need to do when you run into this kind of error is to add the
relevant members to your InstructionSelector. Each target may make
slightly different assumptions about what exists in the
InstructionSelector. This one is pretty obvious from the name, but in
the general case you might have to look at what exists in DAGISel.
Unfortunately, adding the members to InstructionSelector isn't going to work in this case. The ImmLeaf predicates are currently static functions and only have access to the immediate being tested. We're going to have to change how these predicates are generated to give them access to the members of the InstructionSelector.
Hi Leslie. You're going to run into a challenge with GlobalISel and
the RISC-V backend due to our use of variable-sized register classes
(http://lists.llvm.org/pipermail/llvm-dev/2016-September/105027.html).
I believe that neither GlobalISel or FastISel have been updated to
support this concept.
In file included from
/data/project/xiangzhai/llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp:97:
/data/project/xiangzhai/llvm/build/lib/Target/RISCV/RISCVGenGlobalISel.inc:100:7:
error: use of
undeclared identifier 'Subtarget'
if (Subtarget->is64Bit())
^
Even if no errors after comment `if (Subtarget->is64Bit())` in
RISCVInstrInfo.td, but it is monkey patch, and it can't handle riscv64
without the if condition check.
I haven't looked into this, but I would imagine that none of the
patterns using that are supported yet, and that's why we don't see any
errors for ARM yet.
How ARM handle this? and I removed all ARM related code in RISCVXXX.cpp,
only keep skeleton for easy debug, please give me some hint, thanks a lot!
ARMInstructionSelector has an ARMSubtarget reference called STI. We'll
probably have to rename that to Subtarget to support something like
this in the future.
What you need to do when you run into this kind of error is to add the
relevant members to your InstructionSelector. Each target may make
slightly different assumptions about what exists in the
InstructionSelector. This one is pretty obvious from the name, but in
the general case you might have to look at what exists in DAGISel.
In file included from
/data/project/xiangzhai/llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp:97:
/data/project/xiangzhai/llvm/build/lib/Target/RISCV/RISCVGenGlobalISel.inc:100:7:
error: use of
undeclared identifier 'Subtarget'
if (Subtarget->is64Bit())
^
Even if no errors after comment `if (Subtarget->is64Bit())` in
RISCVInstrInfo.td, but it is monkey patch, and it can't handle riscv64
without the if condition check.
I haven't looked into this, but I would imagine that none of the
patterns using that are supported yet, and that's why we don't see any
errors for ARM yet.
How ARM handle this? and I removed all ARM related code in RISCVXXX.cpp,
only keep skeleton for easy debug, please give me some hint, thanks a lot!
ARMInstructionSelector has an ARMSubtarget reference called STI. We'll
probably have to rename that to Subtarget to support something like
this in the future.
What you need to do when you run into this kind of error is to add the
relevant members to your InstructionSelector. Each target may make
slightly different assumptions about what exists in the
InstructionSelector. This one is pretty obvious from the name, but in
the general case you might have to look at what exists in DAGISel.
Unfortunately, adding the members to InstructionSelector isn't going to work in this case. The ImmLeaf predicates are currently static functions and only have access to the immediate being tested. We're going to have to change how these predicates are generated to give them access to the members of the InstructionSelector.
Cool! I will try to hack lib/CodeGen/GlobalISel for learning, thanks!
Hi Leslie. You're going to run into a challenge with GlobalISel and
the RISC-V backend due to our use of variable-sized register classes
(http://lists.llvm.org/pipermail/llvm-dev/2016-September/105027.html).
I believe that neither GlobalISel or FastISel have been updated to
support this concept.
In file included from
/data/project/xiangzhai/llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp:97:
/data/project/xiangzhai/llvm/build/lib/Target/RISCV/RISCVGenGlobalISel.inc:100:7:
error: use of
undeclared identifier ‘Subtarget’
if (Subtarget->is64Bit())
^
Even if no errors after comment if (Subtarget->is64Bit()) in
RISCVInstrInfo.td, but it is monkey patch, and it can’t handle riscv64
without the if condition check.
I haven’t looked into this, but I would imagine that none of the
patterns using that are supported yet, and that’s why we don’t see any
errors for ARM yet.
How ARM handle this? and I removed all ARM related code in RISCVXXX.cpp,
only keep skeleton for easy debug, please give me some hint, thanks a lot!
ARMInstructionSelector has an ARMSubtarget reference called STI. We’ll
probably have to rename that to Subtarget to support something like
this in the future.
What you need to do when you run into this kind of error is to add the
relevant members to your InstructionSelector. Each target may make
slightly different assumptions about what exists in the
InstructionSelector. This one is pretty obvious from the name, but in
the general case you might have to look at what exists in DAGISel.
Unfortunately, adding the members to InstructionSelector isn’t going to work in this case. The ImmLeaf predicates are currently static functions and only have access to the immediate being tested. We’re going to have to change how these predicates are generated to give them access to the members of the InstructionSelector.
I’ve fixed this limitation in r321176 by making the predicate functions members of the InstructionSelector. Starting from that commit, you can resolve the problem with referencing
Subtarget by adding it to the RISCVInstructionSelector as Diana suggested.
In file included from
/data/project/xiangzhai/llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp:97:
/data/project/xiangzhai/llvm/build/lib/Target/RISCV/RISCVGenGlobalISel.inc:100:7:
error: use of
undeclared identifier 'Subtarget'
if (Subtarget->is64Bit())
^
Even if no errors after comment `if (Subtarget->is64Bit())` in
RISCVInstrInfo.td, but it is monkey patch, and it can't handle riscv64
without the if condition check.
I haven't looked into this, but I would imagine that none of the
patterns using that are supported yet, and that's why we don't see any
errors for ARM yet.
How ARM handle this? and I removed all ARM related code in RISCVXXX.cpp,
only keep skeleton for easy debug, please give me some hint, thanks a lot!
ARMInstructionSelector has an ARMSubtarget reference called STI. We'll
probably have to rename that to Subtarget to support something like
this in the future.
What you need to do when you run into this kind of error is to add the
relevant members to your InstructionSelector. Each target may make
slightly different assumptions about what exists in the
InstructionSelector. This one is pretty obvious from the name, but in
the general case you might have to look at what exists in DAGISel.
Unfortunately, adding the members to InstructionSelector isn't going to work in this case. The ImmLeaf predicates are currently static functions and only have access to the immediate being tested. We're going to have to change how these predicates are generated to give them access to the members of the InstructionSelector.
I've fixed this limitation in r321176 by making the predicate functions members of the <Target>InstructionSelector. Starting from that commit, you can resolve the problem with referencing
Subtarget by adding it to the RISCVInstructionSelector as Diana suggested.
[ 48%] Building CXX object lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVInstructionSelector.cpp.o
In file included from /data/project/xiangzhai/llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp:97:
/data/project/xiangzhai/llvm/build/lib/Target/RISCV/RISCVGenGlobalISel.inc:191:65: error: use of
undeclared identifier 'STI'
AvailableFunctionFeatures = computeAvailableFunctionFeatures(&STI, &MF);
^
TableGen expects there to be a member called STI so you can't rename it but you could add Subtarget and initialize it to STI to get things working quickly. Later on, you can try to remove Subtarget again by changing the ImmLeaf predicates that need it.
Alternatively, I suppose we could have TableGen provide Subtarget as an alias. It would be a fairly small and useful change to make if it turns out we have a lot of these predicates.