From 64332a0937f731fe7b090bee7d3e9f813e341e5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timur=20Krist=C3=B3f?= Date: Thu, 23 Apr 2020 15:24:47 +0200 Subject: [PATCH] aco: Const correctness for aco_print_ir. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_ir.h | 4 +-- src/amd/compiler/aco_print_ir.cpp | 48 +++++++++++++++---------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 7769355eab9..812a116eb29 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -1519,8 +1519,8 @@ void collect_presched_stats(Program *program); void collect_preasm_stats(Program *program); void collect_postasm_stats(Program *program, const std::vector& code); -void aco_print_instr(Instruction *instr, FILE *output); -void aco_print_program(Program *program, FILE *output); +void aco_print_instr(const Instruction *instr, FILE *output); +void aco_print_program(const Program *program, FILE *output); /* utilities for dealing with register demand */ RegisterDemand get_live_changes(aco_ptr& instr); diff --git a/src/amd/compiler/aco_print_ir.cpp b/src/amd/compiler/aco_print_ir.cpp index b3fcb74cd58..5bf91cf3a5c 100644 --- a/src/amd/compiler/aco_print_ir.cpp +++ b/src/amd/compiler/aco_print_ir.cpp @@ -178,16 +178,16 @@ static void print_barrier_reorder(bool can_reorder, barrier_interaction barrier, fprintf(output, " gs_sendmsg"); } -static void print_instr_format_specific(struct Instruction *instr, FILE *output) +static void print_instr_format_specific(const Instruction *instr, FILE *output) { switch (instr->format) { case Format::SOPK: { - SOPK_instruction* sopk = static_cast(instr); + const SOPK_instruction* sopk = static_cast(instr); fprintf(output, " imm:%d", sopk->imm & 0x8000 ? (sopk->imm - 65536) : sopk->imm); break; } case Format::SOPP: { - SOPP_instruction* sopp = static_cast(instr); + const SOPP_instruction* sopp = static_cast(instr); uint16_t imm = sopp->imm; switch (instr->opcode) { case aco_opcode::s_waitcnt: { @@ -255,7 +255,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) break; } case Format::SMEM: { - SMEM_instruction* smem = static_cast(instr); + const SMEM_instruction* smem = static_cast(instr); if (smem->glc) fprintf(output, " glc"); if (smem->dlc) @@ -266,12 +266,12 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) break; } case Format::VINTRP: { - Interp_instruction* vintrp = static_cast(instr); + const Interp_instruction* vintrp = static_cast(instr); fprintf(output, " attr%d.%c", vintrp->attribute, "xyzw"[vintrp->component]); break; } case Format::DS: { - DS_instruction* ds = static_cast(instr); + const DS_instruction* ds = static_cast(instr); if (ds->offset0) fprintf(output, " offset0:%u", ds->offset0); if (ds->offset1) @@ -281,7 +281,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) break; } case Format::MUBUF: { - MUBUF_instruction* mubuf = static_cast(instr); + const MUBUF_instruction* mubuf = static_cast(instr); if (mubuf->offset) fprintf(output, " offset:%u", mubuf->offset); if (mubuf->offen) @@ -306,7 +306,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) break; } case Format::MIMG: { - MIMG_instruction* mimg = static_cast(instr); + const MIMG_instruction* mimg = static_cast(instr); unsigned identity_dmask = !instr->definitions.empty() ? (1 << instr->definitions[0].size()) - 1 : 0xf; @@ -366,7 +366,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) break; } case Format::EXP: { - Export_instruction* exp = static_cast(instr); + const Export_instruction* exp = static_cast(instr); unsigned identity_mask = exp->compressed ? 0x5 : 0xf; if ((exp->enabled_mask & identity_mask) != identity_mask) fprintf(output, " en:%c%c%c%c", @@ -394,7 +394,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) break; } case Format::PSEUDO_BRANCH: { - Pseudo_branch_instruction* branch = static_cast(instr); + const Pseudo_branch_instruction* branch = static_cast(instr); /* Note: BB0 cannot be a branch target */ if (branch->target[0] != 0) fprintf(output, " BB%d", branch->target[0]); @@ -403,7 +403,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) break; } case Format::PSEUDO_REDUCTION: { - Pseudo_reduction_instruction* reduce = static_cast(instr); + const Pseudo_reduction_instruction* reduce = static_cast(instr); fprintf(output, " op:%s", reduce_ops[reduce->reduce_op]); if (reduce->cluster_size) fprintf(output, " cluster_size:%u", reduce->cluster_size); @@ -412,7 +412,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) case Format::FLAT: case Format::GLOBAL: case Format::SCRATCH: { - FLAT_instruction* flat = static_cast(instr); + const FLAT_instruction* flat = static_cast(instr); if (flat->offset) fprintf(output, " offset:%u", flat->offset); if (flat->glc) @@ -431,7 +431,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) break; } case Format::MTBUF: { - MTBUF_instruction* mtbuf = static_cast(instr); + const MTBUF_instruction* mtbuf = static_cast(instr); fprintf(output, " dfmt:"); switch (mtbuf->dfmt) { case V_008F0C_BUF_DATA_FORMAT_8: fprintf(output, "8"); break; @@ -481,7 +481,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) break; } case Format::VOP3P: { - if (static_cast(instr)->clamp) + if (static_cast(instr)->clamp) fprintf(output, " clamp"); break; } @@ -490,7 +490,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) } } if (instr->isVOP3()) { - VOP3A_instruction* vop3 = static_cast(instr); + const VOP3A_instruction* vop3 = static_cast(instr); switch (vop3->omod) { case 1: fprintf(output, " *2"); @@ -507,7 +507,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) if (vop3->opsel & (1 << 3)) fprintf(output, " opsel_hi"); } else if (instr->isDPP()) { - DPP_instruction* dpp = static_cast(instr); + const DPP_instruction* dpp = static_cast(instr); if (dpp->dpp_ctrl <= 0xff) { fprintf(output, " quad_perm:[%d,%d,%d,%d]", dpp->dpp_ctrl & 0x3, (dpp->dpp_ctrl >> 2) & 0x3, @@ -544,7 +544,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) if (dpp->bound_ctrl) fprintf(output, " bound_ctrl:1"); } else if ((int)instr->format & (int)Format::SDWA) { - SDWA_instruction* sdwa = static_cast(instr); + const SDWA_instruction* sdwa = static_cast(instr); switch (sdwa->omod) { case 1: fprintf(output, " *2"); @@ -579,7 +579,7 @@ static void print_instr_format_specific(struct Instruction *instr, FILE *output) } } -void aco_print_instr(struct Instruction *instr, FILE *output) +void aco_print_instr(const Instruction *instr, FILE *output) { if (!instr->definitions.empty()) { for (unsigned i = 0; i < instr->definitions.size(); ++i) { @@ -596,7 +596,7 @@ void aco_print_instr(struct Instruction *instr, FILE *output) bool opsel[instr->operands.size()]; uint8_t sel[instr->operands.size()]; if ((int)instr->format & (int)Format::VOP3A) { - VOP3A_instruction* vop3 = static_cast(instr); + const VOP3A_instruction* vop3 = static_cast(instr); for (unsigned i = 0; i < instr->operands.size(); ++i) { abs[i] = vop3->abs[i]; neg[i] = vop3->neg[i]; @@ -604,7 +604,7 @@ void aco_print_instr(struct Instruction *instr, FILE *output) sel[i] = sdwa_udword; } } else if (instr->isDPP()) { - DPP_instruction* dpp = static_cast(instr); + const DPP_instruction* dpp = static_cast(instr); for (unsigned i = 0; i < instr->operands.size(); ++i) { abs[i] = i < 2 ? dpp->abs[i] : false; neg[i] = i < 2 ? dpp->neg[i] : false; @@ -612,7 +612,7 @@ void aco_print_instr(struct Instruction *instr, FILE *output) sel[i] = sdwa_udword; } } else if (instr->isSDWA()) { - SDWA_instruction* sdwa = static_cast(instr); + const SDWA_instruction* sdwa = static_cast(instr); for (unsigned i = 0; i < instr->operands.size(); ++i) { abs[i] = i < 2 ? sdwa->abs[i] : false; neg[i] = i < 2 ? sdwa->neg[i] : false; @@ -659,7 +659,7 @@ void aco_print_instr(struct Instruction *instr, FILE *output) fprintf(output, "|"); if (instr->format == Format::VOP3P) { - VOP3P_instruction* vop3 = static_cast(instr); + const VOP3P_instruction* vop3 = static_cast(instr); if ((vop3->opsel_lo & (1 << i)) || !(vop3->opsel_hi & (1 << i))) { fprintf(output, ".%c%c", vop3->opsel_lo & (1 << i) ? 'y' : 'x', @@ -757,7 +757,7 @@ static void print_stage(Stage stage, FILE *output) fprintf(output, "\n"); } -void aco_print_block(const struct Block* block, FILE *output) +void aco_print_block(const Block* block, FILE *output) { fprintf(output, "BB%d\n", block->index); fprintf(output, "/* logical preds: "); @@ -776,7 +776,7 @@ void aco_print_block(const struct Block* block, FILE *output) } } -void aco_print_program(Program *program, FILE *output) +void aco_print_program(const Program *program, FILE *output) { print_stage(program->stage, output); -- 2.30.2