[PATCH] D37065: [RFC] Stop GenericOpcodes.td from breaking targets that set guessInstructionProperties=0

Alex Bradbury via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 08:09:04 PDT 2017


asb created this revision.

https://reviews.llvm.org/rL162640 introduced CodeGenTarget::guessInstructionProperties. If a target sets guessInstructionProperties=0 in its FootgtInstrInfo, tablegen will error if it has to guess properties from patterns. Unfortunately, this can't be used with current upstream LLVM as GenericOpcodes.td instructions are always included and have inferred properties for mayLoad and mayStore. This patch provides the simplest possible fix to this problem, enclosing these instruction definitions in a scope where mayLoad and mayStore default to 0. The local definitions take precedence, so definitions like G_LOAD have their expected properties and there is no functional change.

Other solutions are of course possible, including:

- Explicitly setting mayLoad and mayStore for each instruction
- Defining a new GInstruction class where mayLoad and mayStore are set to 0, and using this in GenericOpcodes.td
- Deciding guessInstructionProperties is a failed experiment, and remove support for it from LLVM
- Others?

I've submitted this patch with the most straight-forward solution in order to make things concrete. What do you think?


https://reviews.llvm.org/D37065

Files:
  include/llvm/Target/GenericOpcodes.td


Index: include/llvm/Target/GenericOpcodes.td
===================================================================
--- include/llvm/Target/GenericOpcodes.td
+++ include/llvm/Target/GenericOpcodes.td
@@ -12,6 +12,11 @@
 //
 //===----------------------------------------------------------------------===//
 
+// Ensure mayLoad and mayStore have a default value, so these generic opcodes
+// won't break targets that set guessInstructionProperties=1. Any local
+// definition of mayLoad/mayStore takes precedence over these default values.
+let mayLoad = 0, mayStore = 0 in {
+
 //------------------------------------------------------------------------------
 // Unary ops.
 //------------------------------------------------------------------------------
@@ -579,3 +584,5 @@
 }
 
 // TODO: Add the other generic opcodes.
+
+} // End scope with mayLoad=0, mayStore=0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37065.112369.patch
Type: text/x-patch
Size: 863 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170823/1b408c42/attachment.bin>


More information about the llvm-commits mailing list