What's "register pressure set"

Hi everyone,

I'm looking through codes related to registered pressure tracking, mainly the source files 'RegisterPressure.h/cpp', 'MachineRegisterInfo.h/cpp', 'TargetRegisterInfo.h/cpp'.

There is a concept I can hardly understand, the 'register pressure set'. Class 'TargetRegisterInfo' defines two virtual methods 'getRegClassPressureSets' and 'getRegUnitPressureSets' for querying but I don't see any subclasses overriding it.

What's the meaning of the register pressure set? Anyone can give me some help?

Thanks!

Xing

Hi Xing,

The register pressure sets are basically concepts that tells you how may variables can live in register at the same time.
This information is available for two different level of abstraction: per register class and per register unit. The register unit is the basic entity we use to represent a register.

Tablegen generates all of that for you, so you do not need to worry about them.

Cheers,
-Quentin

You can find some notes on how pressure sets are computed in the tablegen source. If you look for the code overriding the virtual functions, you can find that tablegen places the generated code in

$BUILDDIR/lib/Target/XXX/XXXGenRegisterInfo.inc

- Matthias

Hi everyone,

I'm looking through codes related to registered pressure tracking, mainly the source files 'RegisterPressure.h/cpp', 'MachineRegisterInfo.h/cpp', 'TargetRegisterInfo.h/cpp'.

There is a concept I can hardly understand, the 'register pressure set'. Class 'TargetRegisterInfo' defines two virtual methods 'getRegClassPressureSets' and 'getRegUnitPressureSets' for querying but I don't see any subclasses overriding it.

What's the meaning of the register pressure set? Anyone can give me some help?

I wish this were better explained/presented in the interface. It's not really so complicated...

Essentially, a register unit is the smallest granual in the target's register file. Some parts of wider registers may be addressed as smaller subregisters. A pressure set is an abstraction that allows the compiler to track the register usage across different register widths in machine independent code.

Say I have a machine with two 64-bit registers: {R0, R1}
And one of the registers can be addressed as two 32-bit registers: {R0L, R0H}

You need two pressure sets to track usage: P32 and P64.
limit(P32) = 2
limit(P64) = 4

That's not a typo. The 64-bit presure set is 4 deep, even though the machine only has two 64-bit registers.

An assignment to a 64-bit register increments P64 by two units:

R0 = ... // P64 += 2

An assignment to a 32-bit register increments both sets, each by one unit:

R0L = ... // P32 += 1; P64 += 1

The LLVM implementation of all this is extraodinarilly complex because these pressure sets are inferred from arbitrary register definitions, subregister relations, and register classes.

Preciselly tracking pressure using the pressure set abstraction can also be fairly expensive.

-Andy