LOP3 : 3-input Logic Operation

Format

SPA 5.0:
        {@{!}Pg}   LOP3.LUT{.X}{.pop}   Pu, Rd,         Ra, Rb, Rc, #Imm8   {&req_6}   {?sched}   ;   
        {@{!}Pg}   LOP3.LUT{.X}{.pop}       Rd{.CC},    Ra, Sb, Rc, #Imm8   {&req_6}   {?sched}   ;   
        {@{!}Pg}   LOP3.lop{.X}{.pop}   Pu, Rd,      {~}Ra, {~}Rb, {~}Rc    {&req_6}   {?sched}   ;   
        {@{!}Pg}   LOP3.lop{.X}{.pop}       Rd{.CC}, {~}Ra, {~}Sb, {~}Rc    {&req_6}   {?sched}   ;   

 .lop:   logical operation   { .AND, .OR, .XOR, .PASS_B }
 .pop:   predicate operation { .F*, .T, .Z, .NZ }
 .X  :   Extended precision logical operation

 .CC :   Write condition codes

LOP3 allows the following source Sb:
    Sb(register)
    Sb(constant with immediate address)
    Sb(#IMM20)
Note that .pop and Pu can only be used with Sb(register).

Description

An arbitrary bitwise logical function of three sources into one destination.

The #Imm8 specifies which logic function is desired. There are 2^(2^3) logic functions possible for 3 inputs, so all such functions can be specified. The #Imm8 acts as the logic table for the desired function.
For each individual bit i, the result Rd[i] = LUT[ (Ra[i]<<2) | (Sb[i]<<1) | Rc[i] ].

Syntactic sugar is provided for .AND, .OR, .XOR, and .PASS_B, along with optional complements on Ra, Sb, and Rc. This provides similar syntax as LOP, but those are all assembled down to their respective #Imm8 values; a subset of these cases is shown below.

logic function LUT (#Imm8) value
.AND 0b10000000
.OR 0b11111110
.XOR 0b10010110
.PASS_B 0b11001100
It's also possible to emulate the negation of any input, such as:
.AND with ~Sb and ~Rc 0b00010000
.OR with ~Ra and ~Rc 0b11011111
Similarly, one could easily use these functions:
A ^ (B & (A ^ C)) 0b10111000
(A & B) | (A & C) | (B & C) 0b11101000

An extended-precision logical operation is performed by processing words in order from least-significant to most-significant. This order is required so that the sign flag will be set correctly based on the msb of the most-significant word. The zero flag is accumulated by LOP3.X instructions.

If a predicate destination is specified, result of the predicate operation is written back to destination register.
Note that a .pop and predicate destination (Pu) can only be specified if Sb is a register.

Examples:

LOP3.OR       R0, R1, R2, R3;
LOP3.AND  P0, R0, R1, R2, R3;
LOP3.LUT  P0, R0, R1, R2, R3, 0x45;

Back to Index of Instructions