17 Commits

Author SHA1 Message Date
Ana Pazos
23f8b78022 [RISCV] Add support for _interrupt attribute
- Save/restore only registers that are used.
This includes Callee saved registers and Caller saved registers
(arguments and temporaries) for integer and FP registers.
- If there is a call in the interrupt handler, save/restore all
Caller saved registers (arguments and temporaries) and all FP registers.
- Emit special return instructions depending on "interrupt"
attribute type.
Based on initial patch by Zhaoshi Zheng.

Reviewers: asb

Reviewed By: asb

Subscribers: rkruppe, the_o, MartinMosbeck, brucehoult, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, rogfer01, llvm-commits

Differential Revision: https://reviews.llvm.org/D48411

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338047 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-26 17:49:43 +00:00
Mandeep Singh Grang
618f11e436 [RISCV] Lower the tail pseudoinstruction
This patch lowers the tail pseudoinstruction. This has been modeled after ARM's
tail call opt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333137 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-23 22:44:08 +00:00
Alex Bradbury
72eae93f49 [RISCV] Implement isLoadFromStackSlot and isStoreToStackSlot
This causes some slight shuffling but no meaningful codegen differences on the 
corpus I used for testing, but it has a larger impact when combined with e.g. 
rematerialisation. Regardless, it makes sense to report as accurate 
target-specific information as possible.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330949 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-26 15:34:27 +00:00
Shiva Chen
59bf3bda3c [RISCV] Expand function call to "call" pseudoinstruction
To do this:
1. Change GlobalAddress SDNode to TargetGlobalAddress to avoid legalizer
   split the symbol.

2. Change ExternalSymbol SDNode to TargetExternalSymbol to avoid legalizer
   split the symbol.

3. Let PseudoCALL match direct call with target operand TargetGlobalAddress
   and TargetExternalSymbol.

Differential Revision: https://reviews.llvm.org/D44885

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330827 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-25 14:19:12 +00:00
Alex Bradbury
eea8107fac Revert "[RISCV] implement li pseudo instruction"
Reverts rL330224, while issues with the C extension and missed common
subexpression elimination opportunities are addressed. Neither of these issues
are visible in current RISC-V backend unit tests, which clearly need
expanding.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330281 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-18 19:02:31 +00:00
Alex Bradbury
6b11f688f9 [RISCV] implement li pseudo instruction
The implementation follows the MIPS backend and expands the
pseudo instruction directly during asm parsing. As the result, only
real MC instructions are emitted to the MCStreamer. Additionally,
PseudoLI instructions are emitted during codegen. The actual
expansion to real instructions is performed during MI to MC lowering
and is similar to the expansion performed by the GNU Assembler.

Differential Revision: https://reviews.llvm.org/D41949
Patch by Mario Werner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330224 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-17 21:56:40 +00:00
Alex Bradbury
14efaa1e8e [RISCV] Codegen support for RV32D floating point comparison operations
Also add double-prevoius-failure.ll which captures a test case that at one
point triggered a compiler crash, while developing calling convention support
for f64 on RV32D with soft-float ABI.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329877 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 05:50:06 +00:00
Alex Bradbury
633653d6d5 [RISCV] Codegen support for RV32D floating point load/store, fadd.d, calling conv
fadd.d is required in order to force floating point registers to be used in
test code, as parameters are passed in integer registers in the soft float
ABI.

Much of this patch is concerned with support for passing f64 on RV32D with a
soft-float ABI. Similar to Mips, introduce pseudoinstructions to build an f64
out of a pair of i32 and to split an f64 to a pair of i32. BUILD_PAIR and
EXTRACT_ELEMENT can't be used, as a BITCAST to i64 would be necessary, but i64
is not a legal type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329871 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 05:34:25 +00:00
Alex Bradbury
94f16be238 [RISCV] Codegen support for RV32F floating point comparison operations
This patch also includes extensive tests targeted at select and br+fcmp IR
inputs. A sequence of br+fcmp required support for FPR32 registers to be added
to RISCVInstrInfo::storeRegToStackSlot and
RISCVInstrInfo::loadRegFromStackSlot.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328104 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-21 15:11:02 +00:00
Alex Bradbury
8ef96aef09 [RISCV] Implement support for the BranchRelaxation pass
Branch relaxation is needed to support branch displacements that overflow the
instruction's immediate field.

Differential Revision: https://reviews.llvm.org/D40830


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322224 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 21:05:07 +00:00
Alex Bradbury
c752a363cf [RISCV] Implement branch analysis
This is a prerequisite for the branch relaxation pass, and allows a number of
optimisation passes (e.g. BranchFolding and MachineBlockPlacement) to work.

Differential Revision: https://reviews.llvm.org/D40808


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322222 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 20:47:00 +00:00
Alex Bradbury
58c4e96dc9 [RISCV] Support stack frames and offsets up to 32-bits
Differential Revision: https://reviews.llvm.org/D40807


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322216 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 19:53:46 +00:00
Alex Bradbury
499f980e9e [RISCV][NFC] Use TargetRegisterClass::hasSubClassEq in storeRegToStackSlot/loadReadFromStackSlot
Simply checking for register class equality will break once additional 
register classes are added (as is done for the RVC instruction set extension).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320036 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-07 12:45:05 +00:00
Alex Bradbury
da781c7295 [RISCV] Initial support for function calls
Note that this is just enough for simple function call examples to generate 
working code. Support for varargs etc follows in future patches.

Differential Revision: https://reviews.llvm.org/D29936


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317691 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-08 13:41:21 +00:00
Alex Bradbury
eacca308e4 [RISCV] Codegen for conditional branches
A good portion of this patch is the extra functions that needed to be 
implemented to support the test case. e.g. storeRegToStackSlot, 
loadRegFromStackSlot, eliminateFrameIndex.

Setting ISD::BR_CC to Expand may appear non-obvious on an architecture with 
branch+cmp instructions. However, I found it much easier to deal with matching 
the expanded form.

I had to change simm13_lsb0 and simm21_lsb0 to inherit from the 
Operand<OtherVT> class rather than Operand<i32> in order to keep tablegen 
happy. This isn't a big deal, but it does seem a shame to lose the uniformity 
across immediate types when there's not an obvious benefit (I'm hoping a 
tablegen expert will educate me on what I'm missing here!).

Differential Revision: https://reviews.llvm.org/D29935


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317690 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-08 13:31:40 +00:00
Alex Bradbury
21ae2e7a56 [RISCV] Codegen support for memory operations
This required the implementation of RISCVTargetInstrInfo::copyPhysReg. Support
for lowering global addresses follow in the next patch.

Differential Revision: https://reviews.llvm.org/D29934


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317685 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-08 12:20:01 +00:00
Alex Bradbury
5a3d179fab [RISCV] Initial codegen support for ALU operations
This adds the minimum necessary to support codegen for simple ALU operations
on RV32. Prolog and epilog insertion, support for memory operations etc etc 
follow in future patches.

Leave guessInstructionProperties=1 until https://reviews.llvm.org/D37065 is 
reviewed and lands.

Differential Revision: https://reviews.llvm.org/D29933


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316188 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-19 21:37:38 +00:00