freedreno/afuc: Add .align directive

This will be necessary for aligning the sections.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26771>
This commit is contained in:
Connor Abbott
2023-12-18 17:45:14 -05:00
committed by Marge Bot
parent 542ae9de01
commit f7bf4db339
5 changed files with 22 additions and 0 deletions
+8
View File
@@ -123,6 +123,14 @@ decl_jumptbl(void)
instr_offset += 0x80;
}
void
align_instr(unsigned alignment)
{
while (instr_offset % (alignment / 4) != 0) {
next_instr(OPC_NOP);
}
}
static int
resolve_label(const char *str)
{
+1
View File
@@ -38,6 +38,7 @@ struct asm_label {
struct afuc_instr *next_instr(afuc_opc opc);
void decl_label(const char *str);
void decl_jumptbl(void);
void align_instr(unsigned alignment);
static inline uint32_t
parse_reg(const char *str)
+10
View File
@@ -334,6 +334,15 @@ disasm(struct emu *emu)
/* print jump table */
if (jumptbl_offset != ~0) {
if (gpuver >= 7) {
/* The BV/LPAC microcode must be aligned to 32 bytes. On a7xx, by
* convention the firmware aligns the jumptable preceding it instead
* of the microcode itself, with nop instructions. Insert this
* directive to make sure that it stays aligned when reassembling
* even if the user modifies the BR microcode.
*/
printf(".align 32\n");
}
printf("jumptbl:\n");
printf(".jumptbl\n");
@@ -367,6 +376,7 @@ disasm(struct emu *emu)
isa_disasm(emu->instrs, MIN2(sizedwords, jumptbl_offset) * 4, stdout, &options);
if (jumptbl_offset != ~0) {
printf(".align 32\n");
printf("jumptbl:\n");
printf(".jumptbl\n");
if (jumptbl_offset + ARRAY_SIZE(emu->jmptbl) != sizedwords) {
+1
View File
@@ -98,6 +98,7 @@ extern YYSTYPE yylval;
"(sds"[1-3]")" yylval.num = yytext[4] - '0'; return T_SDS;
"(peek)" return TOKEN(T_PEEK);
".align" return TOKEN(T_ALIGN);
".jumptbl" return TOKEN(T_JUMPTBL);
"," return ',';
+2
View File
@@ -173,6 +173,7 @@ label(const char *str)
%token <num> T_XMOV
%token <num> T_SDS
%token <tok> T_ALIGN
%token <tok> T_JUMPTBL
%type <num> reg
@@ -194,6 +195,7 @@ instr_or_label: instr_r
| branch_instr
| other_instr
| T_LABEL_DECL { decl_label($1); }
| T_ALIGN immediate { align_instr($2); }
| T_JUMPTBL { decl_jumptbl(); }
xmov: T_XMOV { $$ = $1; }