Skip to content

Commit

Permalink
[AArch64][GlobalISel] Select G_BR.
Browse files Browse the repository at this point in the history
This is the first unsized instruction we support; move down the
'sized' check to binops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277007 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ahmedbougacha committed Jul 28, 2016
1 parent e4fd36e commit e2c6755
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/Target/AArch64/AArch64InstructionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,27 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const {
LLT Ty = I.getType();
assert(Ty.isValid() && "Generic instruction doesn't have a type");

// FIXME: Support unsized instructions (e.g., G_BR).
if (!Ty.isSized()) {
DEBUG(dbgs() << "Unsized generic instructions are unsupported\n");
return false;
switch (I.getOpcode()) {
case TargetOpcode::G_BR: {
I.setDesc(TII.get(AArch64::B));
I.removeTypes();
return true;
}

// The size (in bits) of the operation, or 0 for the label type.
const unsigned OpSize = Ty.getSizeInBits();

switch (I.getOpcode()) {
case TargetOpcode::G_OR:
case TargetOpcode::G_AND:
case TargetOpcode::G_ADD:
case TargetOpcode::G_SUB: {
DEBUG(dbgs() << "AArch64: Selecting: binop\n");

if (!Ty.isSized()) {
DEBUG(dbgs() << "Generic binop should be sized\n");
return false;
}

// The size (in bits) of the operation, or 0 for the label type.
const unsigned OpSize = Ty.getSizeInBits();

// Reject the various things we don't support yet.
{
const RegisterBank *PrevOpBank = nullptr;
Expand Down
18 changes: 18 additions & 0 deletions test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
define void @and_s32_gpr() { ret void }
define void @and_s64_gpr() { ret void }

define void @unconditional_br() { ret void }

...

---
Expand Down Expand Up @@ -214,3 +216,19 @@ body: |
%0(64) = COPY %x0
%1(64) = G_AND s64 %0, %0
...

---
# CHECK-LABEL: name: unconditional_br
name: unconditional_br
isSSA: true

# CHECK: body:
# CHECK: bb.0:
# CHECK: successors: %bb.0
# CHECK: B %bb.0
body: |
bb.0:
successors: %bb.0
G_BR unsized %bb.0
...

0 comments on commit e2c6755

Please sign in to comment.