1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 20:43:44 +02:00
Commit Graph

12999 Commits

Author SHA1 Message Date
Chris Lattner
0f61d55197 Fixes working towards PR341
llvm-svn: 14839
2004-07-15 01:50:47 +00:00
Chris Lattner
ffd5effa5f Bug fixes for PR341
llvm-svn: 14838
2004-07-15 01:29:12 +00:00
Chris Lattner
d1b726d18f Implement folding of expressions like 'uint cast (int* getelementptr (int*
null, uint 1) to uint)' to a constant integer.  We can only do this with
primitive LLVM types, because other types have target-specific sizes.

llvm-svn: 14837
2004-07-15 01:16:59 +00:00
Chris Lattner
26e5829b8f Yeah, how about those 'primative' types huh?
llvm-svn: 14836
2004-07-15 01:15:53 +00:00
Chris Lattner
de4449ef34 Now that we codegen the portable "sizeof" efficiently, we can use it for
malloc lowering.  This means that lowerallocations doesn't need targetdata
anymore.  yaay.

llvm-svn: 14835
2004-07-15 01:08:08 +00:00
Chris Lattner
210ffe4b77 Improve codegen for the LLVM offsetof/sizeof "operator". Before we compiled
this LLVM function:

int %foo() {
        ret int cast (int** getelementptr (int** null, int 1) to int)
}

into:

foo:
        mov %EAX, 0
        lea %EAX, DWORD PTR [%EAX + 4]
        ret

now we compile it into:

foo:
        mov %EAX, 4
        ret

This sequence is frequently generated by the MSIL front-end, and soon the malloc lowering pass and
Java front-ends as well..

-Chris

llvm-svn: 14834
2004-07-15 00:58:53 +00:00
Chris Lattner
626552badd You cannot pass functions by value, what does that even mean??
llvm-svn: 14833
2004-07-14 23:14:07 +00:00
Chris Lattner
a4870e6ca2 this "feature" is gone
llvm-svn: 14832
2004-07-14 23:12:09 +00:00
Chris Lattner
7397a61a7f This is logically part of the last patch. Just more really horrible code
that is made unnecessary by it.

llvm-svn: 14831
2004-07-14 23:07:13 +00:00
Chris Lattner
d81b8323ee ** Finally DeclareNewGlobalValue is dead!
* Simplify a lot of code because type's cannot be in function symbol tables
* Fix memory leaks in handling of redefined function prototypes
* Don't use SymbolTable directly for stuff that we can go through the Module
  for.
* Fix some minor bugs on obscure testcases like:
      test/Feature/globalredefinition.ll
* Do not create GlobalVariable objects for forward referenced Functions!
* When forward referencing a function in a constant expression, do not create
  a placeholder, add a bunch of references to it, then turn around and
  replaceAllUsesOfWith on it with a new global, deleting the placeholder.
  Instead, when we find the real definition of the global, just use the
  placeholder instead of creating a new object.

This substantially simplifies the asmwriter and should even speed it up on
cases heavy in constantexprs (like C++, Java, MSIL)...

llvm-svn: 14830
2004-07-14 23:03:46 +00:00
Chris Lattner
17ec8fde04 New, horrible, testcase
llvm-svn: 14829
2004-07-14 22:59:47 +00:00
Chris Lattner
7bef7be4c4 * Fairly substantial change. Instead of creating new globalvariables, then
replaceAllUsesWith'ing any forward references, just use the forward
  reference if it exists.

This introduces GetForwardRefForGlobal, which will eventually completely
replace the horrible DeclareNewGlobalValue function.

llvm-svn: 14828
2004-07-14 21:44:00 +00:00
Chris Lattner
5b80b7157a Fold setValueNameMergingDuplicates into ParseGlobalVariable, allowing us
to substantially simplify the result.  In particular, we no longer create
GlobalVariables and then immediately destroy them when they are duplciate
definitions.

The real point of this patch though is that it gets us closer to the
DeclareNewGlobalValue calls...

llvm-svn: 14827
2004-07-14 20:42:57 +00:00
Brian Gaeke
d8746a7ab6 Actually set the endian/pointersize flags on the module being read in!
llvm-svn: 14826
2004-07-14 20:33:13 +00:00
Chris Lattner
fb6e1c2007 Simplify logic.
llvm-svn: 14825
2004-07-14 20:27:12 +00:00
Chris Lattner
9e4dad1400 Make PATypeHolder and friends return non-const pointers to the types they
hold.  Because types are basically immutable anyway, they should not be
referenced as "const Type*" everywhere.  Just "Type*" should suffice!

llvm-svn: 14824
2004-07-14 20:10:26 +00:00
Chris Lattner
7044b0d4e1 Fix a regression from last night. Apparently the CFE is broken and outputs
functions multiple times, expecting them to be merged.  This should be fixed
in the CFE, then here.

llvm-svn: 14823
2004-07-14 19:33:47 +00:00
Misha Brukman
d6a9646f29 Make sure MTSPR instruction is inserted into the BasicBlock
llvm-svn: 14822
2004-07-14 18:26:31 +00:00
Chris Lattner
74bd192fba Implement new helper methods for creating two-index GEP instructions
llvm-svn: 14821
2004-07-14 18:14:33 +00:00
Chris Lattner
91169a26b5 * Change code to use a static_cast instead of reinterpret_cast
* Add comments
* Add two new gep ctors for the very common case of creating a two operand
  GEP instruction.

llvm-svn: 14820
2004-07-14 18:13:54 +00:00
Misha Brukman
0f42826f30 Don't define the same register twice when loading a ConstantPointerRef to a reg
llvm-svn: 14819
2004-07-14 17:57:04 +00:00
Misha Brukman
73d729838f * Fix multiplication by powers of two and otherwise
* Clarify variable name (StoreInst SI instead of LI)

llvm-svn: 14818
2004-07-14 15:29:51 +00:00
Chris Lattner
6472a6b770 Pull out code shared between GV forward-decl and definition processing.
This gives us only a single call site for setValueNameMergingDuplicates.
The next stage is the start merging them together.

llvm-svn: 14811
2004-07-14 08:23:52 +00:00
Chris Lattner
9827ad9f08 Simplify code. Do not allow functions to be redefined more than once.
Since the stupid '%X = const int 4' thing is gone, we can now simplify
setValueNameMergingDuplicates a bit more.

llvm-svn: 14810
2004-07-14 07:12:48 +00:00
Chris Lattner
fafef8ecd1 Remove a gross and crufty "feature" that was never documented and doesn't work.
llvm-svn: 14809
2004-07-14 06:44:56 +00:00
Chris Lattner
633e78c5c6 Finegrainify namespacification
llvm-svn: 14808
2004-07-14 06:39:48 +00:00
Chris Lattner
a262a55378 Revamp handling of labels. In particular, if we create a forward reference
for a basic block, use it when the block is defined instead of deleting it
and creating a new one.  Also, only create at most ONE forward reference
for any block, instead of one for each forward reference.

llvm-svn: 14807
2004-07-14 06:28:35 +00:00
Brian Gaeke
4dc7caee0e Add Machine-CFG edges to SparcV9 MachineBasicBlocks.
llvm-svn: 14806
2004-07-14 05:40:50 +00:00
Chris Lattner
483a35c547 Split the basic block handling case out of getVal into getBBVal.
llvm-svn: 14805
2004-07-14 01:33:11 +00:00
Chris Lattner
183766f21e Make Argument::print more resilient to non-verifiable IR
llvm-svn: 14801
2004-07-13 23:14:34 +00:00
Chris Lattner
1a1afa3566 Catch aggregates passed by value sooner rather than later.
llvm-svn: 14800
2004-07-13 20:09:51 +00:00
Misha Brukman
79b089abff * Specify that FP arith options have 3 operands
* Correctly load FP constants from the constant pool, should be refactored

llvm-svn: 14799
2004-07-13 15:35:45 +00:00
Chris Lattner
1fa594cf7b Actually, use an exception to stop verification. This gives us much better
error messages because verification stops at the first error.

llvm-svn: 14794
2004-07-13 08:48:04 +00:00
Chris Lattner
2d343521e2 There is no reason to abort and print a stack trace if there is a verification
error.  Just print the message like a good little tool.

llvm-svn: 14793
2004-07-13 08:45:41 +00:00
Chris Lattner
96d249c97a Fine-grainify namespacification, prune #include
llvm-svn: 14792
2004-07-13 08:42:12 +00:00
Chris Lattner
ed8ebfdac9 Fix typeo and refactor bb productions to make it possible for us to reuse any
forward reference blocks if they have been created (instead of creating a new
block, replaceAllUsesOfWith, then nuking the placeholder).   This is not yet
implemented.

llvm-svn: 14791
2004-07-13 08:39:15 +00:00
Chris Lattner
3ab20a8c6a Eliminate some mega-cruft here. There is no reason to DERIVE FROM IR CLASSES
just to keep track of some per-object state!  Gaah!  Whoever wrote this stuff...
oh wait, that would be me.  Never mind.

llvm-svn: 14790
2004-07-13 08:28:21 +00:00
Chris Lattner
2314ffe629 Inline the now trivial setValueNameInternal function into both callers
llvm-svn: 14789
2004-07-13 08:12:39 +00:00
Chris Lattner
34682ff049 Now that basic blocks are eagerly inserted into the Function, we can use
the funciton symbol table to check for conflicts instead of having to
keep a shadow named LocalSymtab.  Totally eliminate LocalSymtab.  Verified
that this did not cause a regression on the testcase for PR107.

llvm-svn: 14788
2004-07-13 08:10:10 +00:00
Chris Lattner
83973de5a7 A couple of substantial cleanup fixes:
1. Split setValueName into two separate functions, one that is only used
     at function scope and doesn't have to deal with duplicates, and one
     that can be used either at global or function scope but that does deal
     with conflicts.  Conflicts were only in there because of the crappy old
     CFE and probably should be entirely eliminated.
  2. Insert BasicBlock's into the parent functions when they are created
     instead of when they are complete.  This effects name lookup (for the
     better), which will be exploited in the next patch.

llvm-svn: 14787
2004-07-13 07:59:27 +00:00
Brian Gaeke
f6ec78a335 Fix warning on SparcV9, where sizeof (int) != sizeof (void *).
llvm-svn: 14786
2004-07-13 07:37:43 +00:00
Chris Lattner
7aa45e259a Replace a bunch of complex ConstantPointerRef referring code with simple
code.

llvm-svn: 14785
2004-07-13 06:58:07 +00:00
Chris Lattner
817b562565 Make tblgen not try to be smart. This is better handled in makefiles if
at all.  Patch contributed by Vladimir Prus!

llvm-svn: 14784
2004-07-13 06:11:46 +00:00
Chris Lattner
fca5fee9d5 Factor some code to handle "load (constantexpr cast foo)" just like
"load (cast foo)".  This allows us to compile C++ code like this:

class Bclass {
  public: virtual int operator()() { return 666; }
};

class Dclass: public Bclass {
  public: virtual int operator()() { return 667; }
} ;

int main(int argc, char** argv) {
  Dclass x;
  return x();
}

Into this:

int %main(int %argc, sbyte** %argv) {
entry:
        call void %__main( )
        ret int 667
}

Instead of this:

int %main(int %argc, sbyte** %argv) {
entry:
        %x = alloca "struct.std::bad_typeid"            ; <"struct.std::bad_typeid"*> [#uses=3]
        call void %__main( )
        %tmp.1.i.i = getelementptr "struct.std::bad_typeid"* %x, uint 0, uint 0, uint 0         ; <int (...)***> [#uses=1]
        store int (...)** getelementptr ([3 x int (...)*]*  %vtable for Bclass, int 0, long 2), int (...)*** %tmp.1.i.i
        %tmp.3.i = getelementptr "struct.std::bad_typeid"* %x, int 0, uint 0, uint 0            ; <int (...)***> [#uses=1]
        store int (...)** getelementptr ([3 x int (...)*]*  %vtable for Dclass, int 0, long 2), int (...)*** %tmp.3.i
        %tmp.5 = load int ("struct.std::bad_typeid"*)** cast (int (...)** getelementptr ([3 x int (...)*]*  %vtable for Dclass, int 0, long 2) to int
("struct.std::bad_typeid"*)**)          ; <int ("struct.std::bad_typeid"*)*> [#uses=1]
        %tmp.6 = call int %tmp.5( "struct.std::bad_typeid"* %x )                ; <int> [#uses=1]
	ret int %tmp.6
        ret int 0
}

In order words, we now resolve the virtual function call.

llvm-svn: 14783
2004-07-13 01:49:43 +00:00
Misha Brukman
449715a57d Correctly load FP constants out of the constant pool.
llvm-svn: 14782
2004-07-12 23:49:47 +00:00
Misha Brukman
da8ed5f4d5 Apple's MacOS X is another OS which does not provide alloca() via <alloca.h>
llvm-svn: 14781
2004-07-12 23:37:18 +00:00
Misha Brukman
b7f3d7b04b Implement getModuleMatchQuality and getJITMatchQuality() for PowerPC
llvm-svn: 14780
2004-07-12 23:36:12 +00:00
Misha Brukman
c9bf3b6db9 * Tabs to spaces
* Delete extra blank lines

llvm-svn: 14779
2004-07-12 22:58:07 +00:00
Misha Brukman
34d55eb8a1 New open proj: C/C++ compiler in C++, with link to Ed Willink's C++ yacc grammar
llvm-svn: 14778
2004-07-12 21:10:47 +00:00
Chris Lattner
10686c55cc Add a helper method. The StructType element is completely redundant in most
cases

llvm-svn: 14777
2004-07-12 20:36:08 +00:00