8000 llvm/lib/Target/Blackfin at release_26 · googol-lab/llvm · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
 
 

Blackfin

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.txt

//===– README.txt - Notes for Blackfin Target ------------------*- org -*-===//

Condition codes

Problem with asymmetric SETCC operations

The instruction

CC = R0 < 2

is not symmetric - there is no R0 > 2 instruction. On the other hand, IF CC JUMP can take both CC and !CC as a condition. We cannot pattern-match (brcond (not cc), target), the DAG optimizer removes that kind of thing.

This is handled by creating a pseudo-register NCC that aliases CC. Register classes JustCC and NotCC are used to control the inversion of CC.

CC as an i32 register

The AnyCC register class pretends to hold i32 values. It can only represent the values 0 and 1, but we can copy to and from the D class. This hack makes it possible to represent the setcc instruction without having i1 as a legal type.

In most cases, the CC register is set by a “CC = ..” or BITTST instruction, and then used in a conditional branch or move. The code generator thinks it is moving 32 bits, but the value stays in CC. In other cases, the result of a comparison is actually used as am i32 number, and CC will be copied to a D register.

Stack frames

Use Push/Pop instructions

We should use the push/pop instructions when saving callee-saved registers. The are smaller, and we may even use push multiple instructions.

requiresRegisterScavenging

We need more intelligence in determining when the scavenger is needed. We should keep track of:

  • Spilling D16 registers
  • Spilling AnyCC registers

Assembler

Implement PrintGlobalVariable

Remove LOAD32sym

It’s a hack combining two instructions by concatenation.

Inline Assembly

These are the GCC constraints from bfin/constraints.md:

CodeRegister classLLVM
aPC
dDC
zCall clobbered P (P0, P1, P2)X
DEvenDX
WOddDX
eAccuC
AA0S
BA1S
bIC
vBC
fMC
cCircular I, B, LX
CJustCCS
tLoopTopX
uLoopBottomX
kLoopCountX
xGRC
yRET*, ASTAT, SEQSTAT, USPX
wALLC
ZThe FD-PIC GOT pointer (P3)S
YThe FD-PIC function pointer register (P1)S
q0-q7R0-R7 individually
qAP0
CodeConstant
J1<<N, N<32
Ks3imm3
Ku3uimm3
Ks4imm4
Ku4uimm4
Ks5imm5
Ku5uimm5
Ks7imm7
KN7-imm7
Kshimm16
Kuhuimm16
L~(1<<N)
M10xff
M20xffff
P0-P40-4
PAMacflag, not M
PBMacflag, only M
QSymbol

Support all register classes

DAG combiner

Create test case for each Illegal SETCC case

The DAG combiner may someimes produce illegal i16 SETCC instructions.

SETCC (ctlz x), 5) == const

SETCC (and load, const) == const

SETCC (zext x) == const

SETCC (sext x) == const

Instruction selection

Better imediate constants

Like ARM, build constants as small imm + shift.

Implement cycle counter

We have CYCLES and CYCLES2 registers, but the readcyclecounter intrinsic wants to return i64, and the code generator doesn’t know how to legalize that.

Instruction alternatives

Some instructions come in different variants for example:

D = D + D P = P + P

Cross combinations are not allowed:

P = D + D (bad)

Similarly for the subreg pseudo-instructions:

D16L = EXTRACT_SUBREG D16, bfin_subreg_lo16 P16L = EXTRACT_SUBREG P16, bfin_subreg_lo16

We want to take advantage of the alternative instructions. This could be done by changing the DAG after instruction selection.

Multipatterns for load/store

We should try to identify multipatterns for load and store instructions. The available instruction matrix is a bit irregular.

Loads:

AddrDPD 16zD 16sD16D 8zD 8s
P*******
P++******
P–******
P+uimm5m2**
P+uimm6m4**
P+imm16**
P+imm17m2**
P+imm18m4**
P++P****
FP-uimm7m4**
I**
I++**
I–**
I++M*

Stores:

AddrDPD16HD16LD 8
P*****
P++****
P–****
P+uimm5m2*
P+uimm6m4**
P+imm16*
P+imm17m2*
P+imm18m4**
P++P***
FP-uimm7m4**
I***
I++***
I–***
I++M*

Workarounds and features

Blackfin CPUs have bugs. Each model comes in a number of silicon revisions with different bugs. We learn about the CPU model from the -mcpu switch.

Interpretation of -mcpu value

  • -mcpu=bf527 refers to the latest known BF527 revision
  • -mcpu=bf527-0.2 refers to silicon rev. 0.2
  • -mcpu=bf527-any refers to all known revisions
  • -mcpu=bf527-none disables all workarounds

The -mcpu setting affects the __SILICON_REVISION__ macro and enabled workarounds:

-mcpu__SILICON_REVISION__Workarounds
bf527Def LatestSpecific to latest
bf527-1.3Def 0x0103Specific to 1.3
bf527-anyDef 0xffffAll bf527-x.y
bf527-noneUndefinedNone

These are the known cores and revisions:

CoreSiliconProcessors
Edinburgh0.3, 0.4, 0.5, 0.6BF531 BF532 BF533
Braemar0.2, 0.3BF534 BF536 BF537
Stirling0.3, 0.4, 0.5BF538 BF539
Moab0.0, 0.1, 0.2BF542 BF544 BF548 BF549
Teton0.3, 0.5BF561
Kookaburra0.0, 0.1, 0.2BF523 BF525 BF527
Mockingbird0.0, 0.1BF522 BF524 BF526
Brodie0.0, 0.1BF512 BF514 BF516 BF518

Compiler implemented workarounds

Most workarounds are implemented in header files and source code using the __ADSPBF527__ macros. A few workarounds require compiler support.

AnomalyMacroGCC Switch
Any__WORKAROUNDS_ENABLED
05000074WA_05000074
05000244__WORKAROUND_SPECULATIVE_SYNCS-mcsync-anomaly
05000245__WORKAROUND_SPECULATIVE_LOADS-mspecld-anomaly
05000257WA_05000257
05000283WA_05000283
05000312WA_LOAD_LCREGS
05000315WA_05000315
05000371__WORKAROUND_RETS
05000426__WORKAROUND_INDIRECT_CALLSNot -micplb

GCC feature switches

SwitchDescription
-msimUse simulator runtime
-momit-leaf-frame-pointerOmit frame pointer for leaf functions
-mlow64k
-mcsync-anomaly
-mspecld-anomaly
-mid-shared-library
-mleaf-id-shared-library
-mshared-library-id=
-msep-dataEnable separate data segment
-mlong-callsUse indirect calls
-mfast-fp
-mfdpic
-minline-plt
-mstack-check-l1Do stack checking in L1 scratch memory
-mmulticoreEnable multicore support
-mcoreaBuild for Core A
-mcorebBuild for Core B
-msdramBuild for SDRAM
-micplbAssume ICPLBs are enabled at runtime.
0