llvm-6502/lib/IR
David Blaikie 198d8baafb [opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.

This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.

* This doesn't modify gep operators, only instructions (operators will be
  handled separately)

* Textual IR changes only. Bitcode (including upgrade) and changing the
  in-memory representation will be in separate changes.

* geps of vectors are transformed as:
    getelementptr <4 x float*> %x, ...
  ->getelementptr float, <4 x float*> %x, ...
  Then, once the opaque pointer type is introduced, this will ultimately look
  like:
    getelementptr float, <4 x ptr> %x
  with the unambiguous interpretation that it is a vector of pointers to float.

* address spaces remain on the pointer, not the type:
    getelementptr float addrspace(1)* %x
  ->getelementptr float, float addrspace(1)* %x
  Then, eventually:
    getelementptr float, ptr addrspace(1) %x

Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.

update.py:
import fileinput
import sys
import re

ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile(       r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")

def conv(match, line):
  if not match:
    return line
  line = match.groups()[0]
  if len(match.groups()[5]) == 0:
    line += match.groups()[2]
  line += match.groups()[3]
  line += ", "
  line += match.groups()[1]
  line += "\n"
  return line

for line in sys.stdin:
  if line.find("getelementptr ") == line.find("getelementptr inbounds"):
    if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
      line = conv(re.match(ibrep, line), line)
  elif line.find("getelementptr ") != line.find("getelementptr ("):
    line = conv(re.match(normrep, line), line)
  sys.stdout.write(line)

apply.sh:
for name in "$@"
do
  python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
  rm -f "$name.tmp"
done

The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh

After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).

The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.

Reviewers: rafael, dexonsmith, grosser

Differential Revision: http://reviews.llvm.org/D7636

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
..
AsmWriter.cpp [opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction 2015-02-27 19:29:02 +00:00
AsmWriter.h Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition. 2015-02-15 22:54:22 +00:00
AttributeImpl.h Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition. 2015-02-15 22:54:22 +00:00
Attributes.cpp InstCombine: propagate deref via new addDereferenceableAttr 2015-02-14 19:37:54 +00:00
AutoUpgrade.cpp [X86] Remove AVX2 and SSE2 pslldq and psrldq intrinsics. We can represent them in IR with vector shuffles now. All their uses have been removed from clang in favor of shuffles. 2015-02-18 06:24:44 +00:00
BasicBlock.cpp remove function names from comments; NFC 2015-02-27 18:07:41 +00:00
CMakeLists.txt Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects. 2015-02-11 03:28:02 +00:00
Comdat.cpp IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
ConstantFold.cpp Prefer SmallVector::append/insert over push_back loops. 2015-02-17 15:29:18 +00:00
ConstantFold.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
ConstantRange.cpp [Modules] Move the ConstantRange class into the IR library. This is 2014-03-04 12:24:34 +00:00
Constants.cpp Constants.cpp: Only read 32 bits for float. 2015-02-20 15:11:55 +00:00
ConstantsContext.h Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition. 2015-02-15 22:54:22 +00:00
Core.cpp Fix invalid cast. 2015-02-23 21:51:06 +00:00
DataLayout.cpp DataLayout: Validate that the pref alignment is at least the ABI align 2015-02-16 05:41:55 +00:00
DebugInfo.cpp IR: Add helper to split debug info flags bitfield 2015-02-21 00:45:26 +00:00
DebugInfoMetadata.cpp IR: Change MDFile to directly store the filename/directory 2015-02-20 20:35:17 +00:00
DebugLoc.cpp IR: Cleanup dead code, NFC 2015-01-16 17:31:29 +00:00
DiagnosticInfo.cpp IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
DiagnosticPrinter.cpp Fix typos in comments, NFC 2014-08-29 21:53:01 +00:00
DIBuilder.cpp IR: Drop the scope in DI template parameters 2015-02-18 20:30:45 +00:00
Dominators.cpp [PM] Port domtree to the new pass manager (at last). 2015-01-14 10:19:28 +00:00
Function.cpp InstCombine: propagate deref via new addDereferenceableAttr 2015-02-14 19:37:54 +00:00
GCOV.cpp llvm-cov: Don't use llvm::outs() in library code 2015-01-23 23:09:27 +00:00
Globals.cpp The leak detector is dead, long live asan and valgrind. 2014-12-22 13:00:36 +00:00
GVMaterializer.cpp [Layering] Move GVMaterializer.h into the IR library where its 2014-03-06 03:50:29 +00:00
InlineAsm.cpp Reformat (and remove some tabs) to make debugging this code a 2015-02-10 21:15:06 +00:00
Instruction.cpp The leak detector is dead, long live asan and valgrind. 2014-12-22 13:00:36 +00:00
Instructions.cpp IR: SrcTy == DstTy doesn't imply that a cast is valid 2015-02-16 09:37:35 +00:00
IntrinsicInst.cpp IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
IRBuilder.cpp PlaceSafepoints: use IRBuilder helpers 2015-02-26 00:35:56 +00:00
IRPrintingPasses.cpp [PM] Switch the new pass manager to use a reference-based API for IR 2015-01-05 02:47:05 +00:00
LegacyPassManager.cpp [LPM] A targeted but somewhat horrible fix to the legacy pass manager's 2015-01-28 09:47:21 +00:00
LLVMBuild.txt
LLVMContext.cpp Fix LLVMContext to match what MDKind names that the LL parser permits. Fixes PR21799! 2014-12-11 02:10:28 +00:00
LLVMContextImpl.cpp Revert GCStrategy ownership changes 2015-01-26 18:26:35 +00:00
LLVMContextImpl.h IR: Fix MDType fields from unsigned to uint64_t 2015-02-19 23:56:07 +00:00
Makefile
Mangler.cpp Silencing an "enumeral and non-enumeral type in conditional expression" warning; NFC. 2014-10-28 13:12:13 +00:00
MDBuilder.cpp [IC] Turn non-null MD on pointer loads to range MD on integer loads. 2015-02-25 05:10:25 +00:00
Metadata.cpp IR: Add MDNode::replaceWithPermanent() 2015-02-10 19:13:46 +00:00
MetadataImpl.h Added missing header for the explicit dependency on MDNode. 2015-02-04 00:20:52 +00:00
MetadataTracking.cpp IR: Store RAUW support and Context in the same pointer, NFC 2015-01-19 19:02:06 +00:00
Module.cpp Verifier: Check for null operands in !llvm.module.flags 2015-02-11 09:13:06 +00:00
module.modulemap [modules] Add module maps for LLVM. These are not quite ready for prime-time 2014-05-21 02:46:14 +00:00
Pass.cpp Refactoring cl::parser construction and initialization. 2015-01-22 21:01:12 +00:00
PassManager.cpp [PM] Push the debug option for the new pass manager into the opt tool 2015-01-13 22:42:38 +00:00
PassRegistry.cpp [PM] Remove an unused and rather expensive mapping from an analysis 2014-10-06 00:30:59 +00:00
Statepoint.cpp Add invoke related functionality into StatepointSite classes. 2015-02-19 11:02:11 +00:00
SymbolTableListTraitsImpl.h Canonicalize header guards into a common format. 2014-08-13 16:26:38 +00:00
Type.cpp [slp] Fix a nasty bug in the SLP vectorizer that Joerg pointed out. 2015-02-12 02:30:56 +00:00
TypeFinder.cpp IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
Use.cpp Fix a URL (NFC) 2014-08-21 21:09:24 +00:00
UseListOrder.cpp verify-uselistorder: Force -preserve-bc-use-list-order 2014-08-19 21:08:27 +00:00
User.cpp IR: Cleanup comments for Value, User, and MDNode 2014-10-15 20:28:31 +00:00
Value.cpp isDereferenceablePointer: look through gc.relocate calls 2015-02-09 21:08:03 +00:00
ValueSymbolTable.cpp IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
ValueTypes.cpp
Verifier.cpp Verifier: Unused comdats might not have a corresponding GV 2015-02-20 19:58:48 +00:00