Commit Graph

155 Commits

Author SHA1 Message Date
John Criswell b99b317cba Removed size_t from the parameter list of the malloc() prototype in generated C
code.  This prevents a compiler warning on Sparc that causes the tests to fail.

llvm-svn: 7125
2003-07-08 14:52:09 +00:00
Chris Lattner fd7016a8ba jmp_buf is really a pointer type that is passed around...
llvm-svn: 6935
2003-06-28 19:29:34 +00:00
Chris Lattner 27223935d7 Add support for the Invoke instruction!
llvm-svn: 6934
2003-06-28 17:53:05 +00:00
Chris Lattner a80de5a3be Preserve compatibility with non-gcc compilers
llvm-svn: 6932
2003-06-28 17:15:12 +00:00
Chris Lattner 90921a7eee Fix bug: CBackend/2003-06-28-LinkOnceGlobalVars.llx
llvm-svn: 6931
2003-06-28 17:08:36 +00:00
Joel Stanley fbb9ab4913 - Fixed name mangling conditions to handle 'linkonce' linkage type. In
particular, name mangling for GlobalValues only occurs when the linkage type is
internal or when the name must be mangled to avoid a collision.  See comments in
CWriter::getValueName for more information.

- 'inline' keyword is now emitted for functions with 'linkonce' linkage type.

- Fixed typos.

llvm-svn: 6898
2003-06-25 04:52:09 +00:00
Brian Gaeke 7610971759 It seems likely that floats would need a cast too, because they are
ordinarily promoted to doubles.

llvm-svn: 6894
2003-06-25 03:05:33 +00:00
Brian Gaeke 04bdfe624c Fix 2003-06-23-PromotedExprs.llx -- if we are adding two bytes we better
explicitly cast the result to be a byte, or C will gleefully promote it
to int.

llvm-svn: 6869
2003-06-23 20:00:51 +00:00
Brian Gaeke 87b4f0765c lib/CWriter/Writer.cpp: Copy AsmWriter's ConstantFP checking code here
into a new function FPCSafeToPrint(), and use it in printConstant()
and printFunction() to decide whether we should output ConstantFPs as
floating-point constants or as references to stack-allocated variables.

lib/VMCore/AsmWriter.cpp: Fix an apparent typo in the code mentioned above.

llvm-svn: 6762
2003-06-17 23:55:35 +00:00
Chris Lattner fb70cf528e Fairly major change: emit fixed sized allocas in the entry block as a variable,
instead of a variable pointer and an alloca.  All accesses to the variable then
use the address-of operator to access it.  This plays better with the internal
GCC code generation phases, which bail early on functions which contain allocas.
It also makes the code a bit easier to read.

llvm-svn: 6734
2003-06-17 04:39:14 +00:00
Brian Gaeke 32f27e9f45 Don't include alloca.h on FreeBSD.
llvm-svn: 6728
2003-06-16 23:57:13 +00:00
Chris Lattner 71ec97a6e1 Fix typeo
llvm-svn: 6704
2003-06-16 12:21:19 +00:00
Chris Lattner d994fd3d88 Fix bug: CBackend/2003-06-11-HexConstant.ll
Fix bug: CBackend/2003-06-11-LiteralStringProblem.ll

llvm-svn: 6697
2003-06-16 12:09:09 +00:00
Chris Lattner b630abfd47 Don't output explicit initializers for globals that are zero initialized
llvm-svn: 6651
2003-06-06 07:10:24 +00:00
Chris Lattner 239ff501ac Fix bug: CBackend/2003-06-01-NullPointerType.ll
llvm-svn: 6526
2003-06-02 03:10:53 +00:00
Chris Lattner 886fca4dc2 Fix a bug with casts to bool. This fixes testcase UnitTests/2003-05-31-CastToBool.c
llvm-svn: 6507
2003-06-01 03:36:51 +00:00
Chris Lattner f789f29aaa Eliminate unnecessary ->get calls that are now automatically handled.
llvm-svn: 6397
2003-05-29 15:12:27 +00:00
Chris Lattner 192623ec93 Add support for setjmp/longjmp primitives
Patch checked in for Bill Wendling :)

llvm-svn: 6241
2003-05-17 22:26:33 +00:00
Chris Lattner c009d58eb3 Casts are now unnecessary
llvm-svn: 6199
2003-05-14 17:50:19 +00:00
Chris Lattner 922f4f2bd4 Fix bug: CBackend/2003-05-13-VarArgFunction.ll
In C, a prototype with no arguments is varargs.  A prototype that takes void
has zero args.

llvm-svn: 6172
2003-05-13 20:15:37 +00:00
Chris Lattner 778b947bfc Fix bug: CWriter/2003-05-12-IntegerSizeWarning.c
llvm-svn: 6128
2003-05-12 15:39:31 +00:00
Chris Lattner 7ba4f0a737 Add support for variable argument functions!
llvm-svn: 6044
2003-05-08 18:41:45 +00:00
Chris Lattner 5b5c7933ce Fix bug: UnitTests/2003-05-02-DependantPHI.c
Fix testcase MultiSource/Ptrdist-ks

llvm-svn: 6000
2003-05-03 07:11:00 +00:00
Chris Lattner 57ebe40f57 * Eliminate using decls
* Fix some styleistic things
* Fix bug: CWriter/2002-05-16-NameCollide.ll

llvm-svn: 5988
2003-05-03 03:14:35 +00:00
Chris Lattner 5bc7eb5fd8 Fix problem where labels were being incorrectly elided, and fix problem
where PHI copies where not emitted for the default label of switch insts

llvm-svn: 5882
2003-04-23 19:15:13 +00:00
Chris Lattner 5cc1270689 Fix the super obnoxious "cast to pointer from integer of different size" warnings
llvm-svn: 5881
2003-04-23 19:09:22 +00:00
Chris Lattner 6ee2cf5d89 Remove unneccesary &*
llvm-svn: 5871
2003-04-23 16:36:11 +00:00
Chris Lattner f86060f45a Add support for the switch instruction to the CWriter
llvm-svn: 5847
2003-04-22 20:19:52 +00:00
Joel Stanley e490214bae Fixed alloca declaration problem on sun.
llvm-svn: 5546
2003-02-12 20:45:00 +00:00
Chris Lattner 98cf1f5d64 - Eliminated the deferred symbol table stuff in Module & Function, it really
wasn't an optimization and it was causing lots of bugs.

llvm-svn: 4779
2002-11-20 18:36:02 +00:00
Nick Hildenbrandt e7225c5d3c *** empty log message ***
llvm-svn: 4754
2002-11-18 22:21:52 +00:00
Nick Hildenbrandt cdf2a1811e *** empty log message ***
llvm-svn: 4745
2002-11-18 20:55:50 +00:00
Chris Lattner 060ac498bb _REALLY_ fix the float constant problem
llvm-svn: 4609
2002-11-07 22:12:53 +00:00
Chris Lattner cffe417a68 Print out 'float' constants correctly
llvm-svn: 4607
2002-11-07 19:43:59 +00:00
Nick Hildenbrandt 642f44fe8e Fixes escapeing bug in strings. Fixes test case test/Regression/CBackend/2002-11-06-PrintEscaped.c
llvm-svn: 4583
2002-11-06 21:40:23 +00:00
Nick Hildenbrandt d1f273e97b Loads and stores can't be inlined. This fixes test/Singlesource/matrixTranspose
llvm-svn: 4579
2002-11-06 20:07:54 +00:00
Nick Hildenbrandt 5c5e78482e Fixed bug in Regression/CBackend/2002-10-30-FunctionPointerAlloca.ll
llvm-svn: 4486
2002-11-01 17:37:09 +00:00
Nick Hildenbrandt 85e3d59a1c Casting NULL can cause problems so lets just not cast NULL to anything.
llvm-svn: 4349
2002-10-28 19:54:06 +00:00
Nick Hildenbrandt c7147032f3 *** empty log message ***
llvm-svn: 4343
2002-10-28 19:05:12 +00:00
Nick Hildenbrandt 181dbf0851 Malloc prototyping now works even if the original file had its own prototype for malloc
llvm-svn: 4271
2002-10-23 18:59:40 +00:00
Chris Lattner 8fad3eab59 Fix bug: CBackend/2002-10-16-External.ll
llvm-svn: 4201
2002-10-16 20:08:47 +00:00
Chris Lattner c6e5d688af Fix bug: test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll
llvm-svn: 4190
2002-10-16 00:08:22 +00:00
Nick Hildenbrandt fa6e71e31d Instead of adding stdlib we just prototype malloc correctly.
llvm-svn: 4118
2002-10-11 21:40:44 +00:00
Nick Hildenbrandt 8d354423fc Sun requires you to include stdlib to use malloc
llvm-svn: 4117
2002-10-11 18:41:44 +00:00
Vikram S. Adve 2cc6609e25 Bug fix: In preventing static global variables from being printed twice,
I also prevented external globals from being printed twice, but they
should (extern declaration and definition).

llvm-svn: 4043
2002-10-05 23:43:10 +00:00
Nick Hildenbrandt afff0a25b7 Add parens around constant calls to getelemptr to properly associate the reference
llvm-svn: 4032
2002-10-03 20:47:24 +00:00
Nick Hildenbrandt 2d3eb5a349 I was wrong on the removing of those references on the last commit.
llvm-svn: 4023
2002-10-02 21:14:33 +00:00
Nick Hildenbrandt bff2adb2a4 Removed unneeded reference and dereferences.
llvm-svn: 4016
2002-10-02 18:34:51 +00:00
Nick Hildenbrandt e07698b492 Cleaned up my last check-in.
llvm-svn: 4014
2002-10-02 18:32:35 +00:00
Nick Hildenbrandt e0ba1f25b6 No longer include malloc.h. If protoypes are needed for memory functions they will be present in the byte code and the generated c as well.
llvm-svn: 4013
2002-10-02 18:20:18 +00:00
Nick Hildenbrandt 386834b2f1 Fixed to properly escape quotes in strings.
llvm-svn: 3991
2002-09-30 21:11:55 +00:00
Nick Hildenbrandt 88e87783b8 Strings now handled correctly.
llvm-svn: 3920
2002-09-25 20:29:26 +00:00
Nick Hildenbrandt 9cedce62ee Parenthesis are now added to casts of type array.
llvm-svn: 3892
2002-09-23 21:02:50 +00:00
Chris Lattner 230d832e38 Fix cwriter to not output FP constants in ascii, output them in hex instead.
This fixes a number of FP precision problems, making the output of the
power benchmark closer to the right answer.

Unfortunately, this only addresses FP constants used directly in functions.
Constants referred to by global constants (such as an array of FP values)
aren't helped by this.  Until this happens power won't work.

llvm-svn: 3871
2002-09-20 23:26:33 +00:00
Chris Lattner 79ea4c4aa2 Fix bug: 2002-09-20-VarArgPrototypes.ll
llvm-svn: 3870
2002-09-20 22:32:30 +00:00
Chris Lattner 2895a2f421 Fix output of typedefs to avoid syntax errors.
* We now can correctly Cify the Olden-power benchmark

llvm-svn: 3860
2002-09-20 15:20:24 +00:00
Chris Lattner 7bd37ed1a6 * Add a couple of comments to the output c code
* _FIX_ infinite recursion problem, due to typedefs of a structure being
  printed before the structure.

llvm-svn: 3859
2002-09-20 15:18:30 +00:00
Chris Lattner 32d812feff Another change that doesn't affect functionality. Since we are only looking
at types in the symbol table, only traverse the type plane, saving a loop nest.

llvm-svn: 3858
2002-09-20 15:12:13 +00:00
Chris Lattner 9a973b4f6a Make the StructPrinted set only take memory when it's being used.
rename parseStruct to printContainedStructs

llvm-svn: 3857
2002-09-20 15:05:40 +00:00
Chris Lattner 37bd117997 No functionality changes, primarily just changing tab indentation to space
indentation

llvm-svn: 3856
2002-09-20 14:56:54 +00:00
Vikram S. Adve 9d0fb1aac5 Don't print global variable definitions twice! Sun's pathetic compiler
never complained about this.

llvm-svn: 3774
2002-09-17 11:50:38 +00:00
Vikram S. Adve 5c5c617b95 No longer need to sign-extend array indices to 64 bits since they
are now longs and not unsigned ints.

llvm-svn: 3731
2002-09-15 21:51:04 +00:00
Nick Hildenbrandt e89a6ebddd Fixed problem with printing struct definitions in the correct order.
This allows for the Regression/Transforms/ScalarReplacement/scalarize.c to run correctly.

llvm-svn: 3721
2002-09-14 21:36:24 +00:00
Chris Lattner d1a21f46ef Fix a bug introduced by the Getelementptr change
llvm-svn: 3695
2002-09-12 20:34:47 +00:00
Chris Lattner b9d9e0ff8d - Change getelementptr instruction to use long indexes instead of uint
indexes for sequential types.

llvm-svn: 3681
2002-09-11 01:21:29 +00:00
Chris Lattner c61f6b0589 - Fix bug: test/Regression/CBackend/2002-08-20-RecursiveTypes.ll
- Converted CWriter to be an LLVM pass.

llvm-svn: 3558
2002-08-31 00:29:16 +00:00
Chris Lattner 91680b53f4 Fix bug: test/Regression/CBackend/2002-08-26-IndirectCallTest.ll
llvm-svn: 3511
2002-08-26 20:50:09 +00:00
Vikram S. Adve 8a5c9b15ae Fix the way parens are printed around "*ptrName" so that
no parens are printed around  *, **, ... alone, except if
it is a pointer type for which no name should be printed,
as in the result of a cast.

llvm-svn: 3506
2002-08-25 20:00:08 +00:00
Vikram S. Adve bc27523001 Sign-extend array index expressions to work correctly on non-32 bit machines.
llvm-svn: 3496
2002-08-24 14:44:23 +00:00
Anand Shukla 83a3654838 Changed default value of 3rd parameter in function definition
llvm-svn: 3492
2002-08-23 10:55:49 +00:00
Chris Lattner 030effa42c Load & StoreInst no longer derive from MemAccessInst, so we don't have
to handle indexing anymore

llvm-svn: 3484
2002-08-22 22:48:55 +00:00
Chris Lattner 7934dad0a0 Fix bug: 2002-08-20-UnnamedArgument.c
llvm-svn: 3401
2002-08-20 16:55:48 +00:00
Chris Lattner f3a86f0b57 Implement ConstantExprs in CWriter
llvm-svn: 3394
2002-08-19 23:09:46 +00:00
Chris Lattner 9ccab2c89b Incorporate calcTypeNameVar into CWriter class, fixing
test/Regression/CBackend/2002-08-19-FunctionPointer.c in the process

llvm-svn: 3392
2002-08-19 22:17:53 +00:00
Chris Lattner b5815279c6 Output forward definitions of global vars to handle recursive intializers correctly.
llvm-svn: 3391
2002-08-19 21:48:40 +00:00
Chris Lattner fda3b293d8 - Change constant printing to be better integrated with the rest of the
CWriter class.  Write directly to stream instead of building a big
      string, then writing it out.
    - Implement printing of ConstantPointerRefs

llvm-svn: 3389
2002-08-19 21:32:41 +00:00
Chris Lattner 7a74051566 Remove support for NOT instruction
llvm-svn: 3320
2002-08-14 18:00:52 +00:00
Chris Lattner f200f7b11a Avoid warning message
llvm-svn: 3085
2002-07-25 16:30:45 +00:00
Chris Lattner e8b6196f28 Fix anands changes
llvm-svn: 2806
2002-06-30 16:07:20 +00:00
Anand Shukla 7e9d0710e6 added include<iostream> for cerr
llvm-svn: 2796
2002-06-25 21:29:10 +00:00
Anand Shukla eaa2e7204e changes to make it compatible with 64bit gcc
llvm-svn: 2790
2002-06-25 20:44:04 +00:00
Chris Lattner f8b0668cc1 * Update with MegaPatch
* Fix various bugs

llvm-svn: 2774
2002-06-25 15:57:03 +00:00
Chris Lattner c839a2574e * Fix typeo
* Provide a #include of <malloc.h> so that the sun C compiler does not
  miscompile malloc function calls

llvm-svn: 2702
2002-05-21 21:10:04 +00:00
Chris Lattner e7c7df07f3 Fix bug: test/Regression/CBackend/2002-05-21-MissingReturn.ll
llvm-svn: 2690
2002-05-21 18:05:19 +00:00
Chris Lattner 5b3057bb82 Fix bug: test/Regression/CBackend/2002-05-16-NameCollide.ll by tracking
which global variables would have name collisions if they were not mangled,
and use this info to mangle them iff they would collide.

llvm-svn: 2639
2002-05-17 04:55:35 +00:00
Chris Lattner e291226f02 Last minor cleanups, this code still does not work for all cases, but it
works much better than it used to.

llvm-svn: 2588
2002-05-09 21:31:18 +00:00
Chris Lattner d4c569c973 Two Cleanups to generated C code:
1. Avoid printing *(&globalvariable), instead print globalvariable alone
   as a special case.
2. Inline subexpressions into expressions as much as legal that preserves
   execution characteristics of expressions.  Now we get nice (but
   over-parenthesized, oh well) things like:

     ltmp_428_7 = spec__putc(((unsigned char )((bsBuff) >> 24)), (bsStream));

   instead of five seperate instructions (bsBuff & bsStream are globals).

llvm-svn: 2587
2002-05-09 21:18:38 +00:00
Chris Lattner 5d190e2192 * Remove CInstPrintVisitor class, incorporating it into the CWriter class
* Reorder code in the file to make it more logically laid out.

llvm-svn: 2586
2002-05-09 20:53:56 +00:00
Chris Lattner 2051c06119 Remove CLocalVars data structure entirely, instead of building stuff and
then printing it out, just print as we go.

llvm-svn: 2585
2002-05-09 20:39:03 +00:00
Chris Lattner 5166d35e5d Simplify code by removing InstLocalVarsVisitor, replacing it with a simple
inst_iterator.

llvm-svn: 2584
2002-05-09 20:33:35 +00:00
Chris Lattner 30ad3a3238 * Clean up how PHI nodes are handled
* Correct global variable references
* Fix loads & stores with zero indices
* Do not emit an else part of a branch if there is no code (no phi node
  and a fallthrough branch), makes code more readable to get:
  if (l2_cond240) {
    goto l13_bb10;
  }

with no else{} branch

llvm-svn: 2583
2002-05-09 20:14:10 +00:00
Chris Lattner 48cd6330d7 Emit:
l3_reg109 = l81_this->field0;
Instead of:
  l3_reg109 = l81_this[0u].field0;

where possible

llvm-svn: 2579
2002-05-09 15:59:50 +00:00
Chris Lattner 4933e7e02d * Print structures types correctly
* Clean up generated code to not emit basic block labels and goto
  instructions if they are unneccesary (for example, fall throughs)

llvm-svn: 2578
2002-05-09 15:49:41 +00:00
Chris Lattner 132ba2a411 * Continue cleanup of type printing code
* Print a newline after a malloc instruction
* Convert unprintable characters to x_ instead of _x so that we don't
  generate identifiers that start with underscores

llvm-svn: 2577
2002-05-09 15:18:52 +00:00
Chris Lattner eed155e6a0 Gut the type printing code so there is only one copy of it instead of 3
llvm-svn: 2576
2002-05-09 14:40:11 +00:00
Chris Lattner c99a44eb25 * Remove dead "constant printing" code
* Mangle names with only a prefix so that they are easier on the eyes.
* Put spaces around binary operators with low precedence to make them easier to read
* Don't prefix function names with &, although it's correct, it's unnecesary and
  easier to read without it.

llvm-svn: 2575
2002-05-09 05:16:40 +00:00
Chris Lattner 1532dbfead Remove gross "Operand" instance variable
Remove lots of unneccesary arguments to methods

llvm-svn: 2574
2002-05-09 04:39:00 +00:00
Chris Lattner c897bddb17 Simplify and clean up function calls.
Now indirect function calls work, except that function pointer types are not correct.

llvm-svn: 2573
2002-05-09 04:21:21 +00:00
Chris Lattner 2fca988a57 * Remove dead function
* Print C strings correctly
* Expand C escape sequences nicely (ie \n \t, etc get generated instead of hex escapes)

llvm-svn: 2572
2002-05-09 03:56:52 +00:00
Chris Lattner af14c8d51f Make Getelementptr, load & store all work the right way.
Handle global variables correctly.

llvm-svn: 2571
2002-05-09 03:50:42 +00:00