[PATCH] D104409: GlobalISel/Utils: Refactor integer/float constant match functions

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 7 13:21:36 PDT 2021


paquette added a comment.

What is the motivation behind adding G to the function names? Given that GlobalISel uses G_* as a prefix for all opcode names, it seems kind of redundant to me.



================
Comment at: llvm/lib/CodeGen/GlobalISel/Utils.cpp:354-356
+bool isGConstant(const MachineInstr *MI) {
+  return MI->getOpcode() == TargetOpcode::G_CONSTANT;
+}
----------------
Petar.Avramovic wrote:
> I thought to make this public. There are many opcode checks like this, most often in asserts.
> Do you find it useful?
I don't know if it really improves on the existing opcode checks all too much.

(This would also probably need a check for nullptr or an assert?)


================
Comment at: llvm/lib/CodeGen/GlobalISel/Utils.cpp:363
+bool isGOrGFConstant(const MachineInstr *MI) {
+  unsigned Opc = MI->getOpcode();
+  return Opc == TargetOpcode::G_CONSTANT || Opc == TargetOpcode::G_FCONSTANT;
----------------
Check for nullptr or assert?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104409/new/

https://reviews.llvm.org/D104409



More information about the llvm-commits mailing list