Eliminate tabs and trailing spaces

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21479 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jeff Cohen 2005-04-23 21:26:11 +00:00
parent cc1f24585e
commit b02fbfc485
25 changed files with 1088 additions and 1089 deletions

File diff suppressed because it is too large Load Diff

View File

@ -46,176 +46,176 @@ class StackerCompiler
/// @name Constructors and Operators
/// @{
public:
/// Default Constructor
StackerCompiler();
/// Default Constructor
StackerCompiler();
/// Destructor
~StackerCompiler();
/// Destructor
~StackerCompiler();
private:
/// Do not copy StackerCompilers
StackerCompiler(const StackerCompiler&);
/// Do not copy StackerCompilers
StackerCompiler(const StackerCompiler&);
/// Do not copy StackerCompilers.
StackerCompiler& operator=(const StackerCompiler& );
/// Do not copy StackerCompilers.
StackerCompiler& operator=(const StackerCompiler& );
/// @}
/// @name High Level Interface
/// @{
public:
/// @brief Compile a single file to LLVM bytecode.
///
/// To use the StackerCompiler, just create one on
/// the stack and call this method.
Module* compile(
const std::string& filename, ///< File to compile
bool echo, ///< Causes compiler to echo output
/// @brief Compile a single file to LLVM bytecode.
///
/// To use the StackerCompiler, just create one on
/// the stack and call this method.
Module* compile(
const std::string& filename, ///< File to compile
bool echo, ///< Causes compiler to echo output
unsigned optLevel, ///< Level of optimization
size_t stack_size ); ///< Size of generated stack
size_t stack_size ); ///< Size of generated stack
/// @}
/// @name Accessors
/// @{
public:
/// @brief Returns the name of the file being compiled.
std::string& filename() { return CurFilename; }
/// @brief Returns the name of the file being compiled.
std::string& filename() { return CurFilename; }
/// @}
/// @name Parse Handling Methods
/// @{
private:
/// Allow only the parser to access these methods. No
/// one else should call them.
friend int Stackerparse();
/// Allow only the parser to access these methods. No
/// one else should call them.
friend int Stackerparse();
/// @brief Handle the start of a module
Module* handle_module_start();
/// @brief Handle the start of a module
Module* handle_module_start();
/// @brief Handle the end of a module
/// @param mod The module we're defining.
Module* handle_module_end( Module* mod );
/// @brief Handle the end of a module
/// @param mod The module we're defining.
Module* handle_module_end( Module* mod );
/// @brief Handle the start of a list of definitions
Module* handle_definition_list_start( );
/// @brief Handle the start of a list of definitions
Module* handle_definition_list_start( );
/// @brief Handle the end of a list of definitions
/// @param mod The module we're constructing
/// @param definition A definition (function) to add to the module
Module* handle_definition_list_end( Module* mod, Function* definition );
/// @brief Handle the end of a list of definitions
/// @param mod The module we're constructing
/// @param definition A definition (function) to add to the module
Module* handle_definition_list_end( Module* mod, Function* definition );
/// @brief Handle creation of the MAIN definition
/// @param func The function to be used as the MAIN definition
Function* handle_main_definition( Function* func );
/// @brief Handle creation of the MAIN definition
/// @param func The function to be used as the MAIN definition
Function* handle_main_definition( Function* func );
/// @brief Handle a forward definition
/// @param name The name of the definition being declared
Function* handle_forward( char* name );
/// @brief Handle a forward definition
/// @param name The name of the definition being declared
Function* handle_forward( char* name );
/// @brief Handle a general definition
/// @param name The name of the definition being defined
/// @param func The Function definition.
Function* handle_definition( char* name, Function* func );
/// @brief Handle a general definition
/// @param name The name of the definition being defined
/// @param func The Function definition.
Function* handle_definition( char* name, Function* func );
/// @brief Handle the start of a definition's word list
Function* handle_word_list_start();
/// @brief Handle the start of a definition's word list
Function* handle_word_list_start();
/// @brief Handle the end of a definition's word list
/// @param func The function to which the basic block is added
/// @param next The block to add to the function
Function* handle_word_list_end( Function* func, BasicBlock* next );
/// @brief Handle the end of a definition's word list
/// @param func The function to which the basic block is added
/// @param next The block to add to the function
Function* handle_word_list_end( Function* func, BasicBlock* next );
/// @brief Handle an if statement, possibly without an else
/// @brief ifTrue The block to execute if true
/// @brief ifFalse The optional block to execute if false
BasicBlock* handle_if( char* ifTrue, char* ifFalse = 0 );
/// @brief Handle an if statement, possibly without an else
/// @brief ifTrue The block to execute if true
/// @brief ifFalse The optional block to execute if false
BasicBlock* handle_if( char* ifTrue, char* ifFalse = 0 );
/// @brief Handle a while statement
/// @brief todo The block to repeatedly execute
BasicBlock* handle_while( char* todo );
/// @brief Handle a while statement
/// @brief todo The block to repeatedly execute
BasicBlock* handle_while( char* todo );
/// @brief Handle an identifier to call the identified definition
/// @param name The name of the identifier to be called.
BasicBlock* handle_identifier( char * name );
/// @brief Handle an identifier to call the identified definition
/// @param name The name of the identifier to be called.
BasicBlock* handle_identifier( char * name );
/// @brief Handle the push of a string onto the stack
/// @param value The string to be pushed.
BasicBlock* handle_string( char * value );
/// @brief Handle the push of a string onto the stack
/// @param value The string to be pushed.
BasicBlock* handle_string( char * value );
/// @brief Handle the push of an integer onto the stack.
/// @param value The integer value to be pushed.
BasicBlock* handle_integer( const int64_t value );
/// @brief Handle the push of an integer onto the stack.
/// @param value The integer value to be pushed.
BasicBlock* handle_integer( const int64_t value );
/// @brief Handle one of the reserved words (given as a token)
BasicBlock* handle_word( int tkn );
/// @brief Handle one of the reserved words (given as a token)
BasicBlock* handle_word( int tkn );
/// @}
/// @name Utility functions
/// @{
public:
/// @brief Throws an exception to indicate an error
/// @param message The message to be output
/// @param line Override for the current line no
static inline void ThrowException( const std::string &message,
int line = -1)
{
if (line == -1) line = Stackerlineno;
// TODO: column number in exception
throw ParseException(TheInstance->CurFilename, message, line);
}
/// @brief Throws an exception to indicate an error
/// @param message The message to be output
/// @param line Override for the current line no
static inline void ThrowException( const std::string &message,
int line = -1)
{
if (line == -1) line = Stackerlineno;
// TODO: column number in exception
throw ParseException(TheInstance->CurFilename, message, line);
}
private:
/// @brief Generate code to increment the stack index
Instruction* incr_stack_index( BasicBlock* bb, Value* );
/// @brief Generate code to decrement the stack index.
Instruction* decr_stack_index( BasicBlock* bb, Value* );
/// @brief Generate code to dereference the top of stack.
Instruction* get_stack_pointer( BasicBlock* bb, Value* );
/// @brief Generate code to push any value onto the stack.
Instruction* push_value( BasicBlock* bb, Value* value );
/// @brief Generate code to push a constant integer onto the stack.
Instruction* push_integer( BasicBlock* bb, int64_t value );
/// @brief Generate code to pop an integer off the stack.
Instruction* pop_integer( BasicBlock* bb );
/// @brief Generate code to push a string pointer onto the stack.
Instruction* push_string( BasicBlock* bb, const char* value );
/// @brief Generate code to pop a string pointer off the stack.
Instruction* pop_string( BasicBlock* bb );
/// @brief Generate code to get the top stack element.
Instruction* stack_top( BasicBlock* bb, Value* index );
/// @brief Generate code to get the top stack element as a string.
Instruction* stack_top_string( BasicBlock* bb, Value* index );
/// @brief Generate code to replace the top element of the stack.
Instruction* replace_top( BasicBlock* bb, Value* new_top, Value* index);
/// @brief Generate code to increment the stack index
Instruction* incr_stack_index( BasicBlock* bb, Value* );
/// @brief Generate code to decrement the stack index.
Instruction* decr_stack_index( BasicBlock* bb, Value* );
/// @brief Generate code to dereference the top of stack.
Instruction* get_stack_pointer( BasicBlock* bb, Value* );
/// @brief Generate code to push any value onto the stack.
Instruction* push_value( BasicBlock* bb, Value* value );
/// @brief Generate code to push a constant integer onto the stack.
Instruction* push_integer( BasicBlock* bb, int64_t value );
/// @brief Generate code to pop an integer off the stack.
Instruction* pop_integer( BasicBlock* bb );
/// @brief Generate code to push a string pointer onto the stack.
Instruction* push_string( BasicBlock* bb, const char* value );
/// @brief Generate code to pop a string pointer off the stack.
Instruction* pop_string( BasicBlock* bb );
/// @brief Generate code to get the top stack element.
Instruction* stack_top( BasicBlock* bb, Value* index );
/// @brief Generate code to get the top stack element as a string.
Instruction* stack_top_string( BasicBlock* bb, Value* index );
/// @brief Generate code to replace the top element of the stack.
Instruction* replace_top( BasicBlock* bb, Value* new_top, Value* index);
/// @}
/// @name Data Members (used during parsing)
/// @{
public:
static StackerCompiler* TheInstance; ///< The instance for the parser
static StackerCompiler* TheInstance; ///< The instance for the parser
private:
std::string CurFilename; ///< Current file name
Module* TheModule; ///< Module instance we'll build
Function* TheFunction; ///< Function we're building
FunctionType* DefinitionType; ///< FT for Definitions
GlobalVariable* TheStack; ///< For referencing _stack_
GlobalVariable* TheIndex; ///< For referencing _index_
Function* TheScanf; ///< External input function
Function* ThePrintf; ///< External output function
Function* TheExit; ///< External exit function
GlobalVariable* StrFormat; ///< Format for strings
GlobalVariable* NumFormat; ///< Format for numbers
GlobalVariable* ChrFormat; ///< Format for chars
GlobalVariable* InStrFormat; ///< Format for input strings
GlobalVariable* InNumFormat; ///< Format for input numbers
GlobalVariable* InChrFormat; ///< Format for input chars
ConstantInt* Zero; ///< long constant 0
ConstantInt* One; ///< long constant 1
ConstantInt* Two; ///< long constant 2
ConstantInt* Three; ///< long constant 3
ConstantInt* Four; ///< long constant 4
ConstantInt* Five; ///< long constant 5
std::vector<Value*> no_arguments; ///< no arguments for Stacker
bool echo; ///< Echo flag
size_t stack_size; ///< Size of stack to gen.
ArrayType* stack_type; ///< The type of the stack
std::string CurFilename; ///< Current file name
Module* TheModule; ///< Module instance we'll build
Function* TheFunction; ///< Function we're building
FunctionType* DefinitionType; ///< FT for Definitions
GlobalVariable* TheStack; ///< For referencing _stack_
GlobalVariable* TheIndex; ///< For referencing _index_
Function* TheScanf; ///< External input function
Function* ThePrintf; ///< External output function
Function* TheExit; ///< External exit function
GlobalVariable* StrFormat; ///< Format for strings
GlobalVariable* NumFormat; ///< Format for numbers
GlobalVariable* ChrFormat; ///< Format for chars
GlobalVariable* InStrFormat; ///< Format for input strings
GlobalVariable* InNumFormat; ///< Format for input numbers
GlobalVariable* InChrFormat; ///< Format for input chars
ConstantInt* Zero; ///< long constant 0
ConstantInt* One; ///< long constant 1
ConstantInt* Two; ///< long constant 2
ConstantInt* Three; ///< long constant 3
ConstantInt* Four; ///< long constant 4
ConstantInt* Five; ///< long constant 5
std::vector<Value*> no_arguments; ///< no arguments for Stacker
bool echo; ///< Echo flag
size_t stack_size; ///< Size of stack to gen.
ArrayType* stack_type; ///< The type of the stack
/// @}
};

View File

@ -1,11 +1,11 @@
//===-- stacker_rt.c - Runtime Support For Stacker Compiler -----*- C++ -*-===//
//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Reid Spencer and donated to the LLVM research
// group and is distributed under the University of Illinois Open Source
// This file was developed by Reid Spencer and donated to the LLVM research
// group and is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//
//===----------------------------------------------------------------------===//
//
// This file defines a stack dumping function that can be used for debugging.
@ -33,7 +33,7 @@ _stacker_dump_stack_()
printf("Stack Dump:\n");
for (i = _index_; i > 0; i-- )
{
printf("#%03lld: %lld\n", (long long int) i, (long long int) _stack_[i] );
printf("#%03lld: %lld\n", (long long int) i, (long long int) _stack_[i] );
}
}
@ -50,14 +50,14 @@ main ( int argc, char** argv )
// so that they get popped in the order presented
while ( a > 0 )
{
if ( isdigit( (int) argv[--a][0] ) )
{
_stack_[_index_++] = atoll( argv[a] );
}
else
{
_stack_[_index_++] = (int64_t) (intptr_t) argv[a];
}
if ( isdigit( (int) argv[--a][0] ) )
{
_stack_[_index_++] = atoll( argv[a] );
}
else
{
_stack_[_index_++] = (int64_t) (intptr_t) argv[a];
}
}
// Put the argument count on the stack
@ -68,6 +68,6 @@ main ( int argc, char** argv )
// Return last item on the stack
if ( _index_ >= 0 )
return _stack_[_index_];
return _stack_[_index_];
return -1;
}

View File

@ -34,14 +34,14 @@ InputFilename(cl::Positional, cl::desc("<input .st file>"), cl::init("-"));
static cl::opt<std::string>
OutputFilename("o", cl::desc("Override output filename"),
cl::value_desc("filename"));
cl::value_desc("filename"));
static cl::opt<bool>
Force("f", cl::desc("Overwrite output files"));
static cl::opt<uint32_t>
StackSize("s", cl::desc("Specify program maximum stack size"),
cl::init(1024), cl::value_desc("stack size"));
cl::init(1024), cl::value_desc("stack size"));
static cl::opt<bool>
DumpAsm("d", cl::desc("Print LLVM Assembly as parsed"), cl::Hidden);

View File

@ -1,8 +1,8 @@
/*
* File: sample.h
*
* This is a sample header file that is global to the entire project.
* It is located here so that everyone will find it.
* This is a sample header file that is global to the entire project.
* It is located here so that everyone will find it.
*/
extern int compute_sample (int a);

View File

@ -2,9 +2,9 @@
* File: sample.c
*
* Description:
* This is a sample source file for a library. It helps to demonstrate
* how to setup a project that uses the LLVM build system, header files,
* and libraries.
* This is a sample source file for a library. It helps to demonstrate
* how to setup a project that uses the LLVM build system, header files,
* and libraries.
*/
#include <stdio.h>
@ -19,6 +19,6 @@
int
compute_sample (int a)
{
return a;
return a;
}

View File

@ -8,7 +8,7 @@
int
main (int argc, char ** argv)
{
printf ("%d\n", compute_sample (5));
exit (0);
printf ("%d\n", compute_sample (5));
exit (0);
}

View File

@ -2,10 +2,10 @@
struct duration {
duration operator/=(int c) {
return *this;
return *this;
}
};
void a000090() {
duration() /= 1;
duration() /= 1;
}

View File

@ -5,13 +5,13 @@
// was mistakenly "thinking" that 'foo' took a structure by component.
struct C {
int A, B;
~C() {}
int A, B;
~C() {}
};
void foo(C b);
void test(C *P) {
foo(*P);
foo(*P);
}

View File

@ -1,16 +1,16 @@
// RUN: %llvmgcc -S %s -o - | llvm-as -f -o /dev/null
/* This testcase causes a symbol table collision. Type names and variable
/* This testcase causes a symbol table collision. Type names and variable
* names should be in distinct namespaces
*/
typedef struct foo {
int X, Y;
int X, Y;
} FOO;
static FOO foo[100];
int test() {
return foo[4].Y;
return foo[4].Y;
}

View File

@ -3,7 +3,6 @@
/* GCC wasn't handling 64 bit constants right fixed */
void main() {
long long Var = 123455678902ll;
printf("%lld\n", Var);
long long Var = 123455678902ll;
printf("%lld\n", Var);
}

View File

@ -3,8 +3,8 @@
#include <string.h>
int test(char *X) {
/* LLVM-GCC used to emit:
%.LC0 = internal global [3 x sbyte] c"\1F\FFFFFF8B\00"
*/
return strcmp(X, "\037\213");
/* LLVM-GCC used to emit:
%.LC0 = internal global [3 x sbyte] c"\1F\FFFFFF8B\00"
*/
return strcmp(X, "\037\213");
}

View File

@ -1,10 +1,10 @@
// RUN: %llvmgcc -S %s -o - | llvm-as -f -o /dev/null
/* GCC was not escaping quotes in string constants correctly, so this would
/* GCC was not escaping quotes in string constants correctly, so this would
* get emitted:
* %.LC1 = internal global [32 x sbyte] c"*** Word "%s" on line %d is not\00"
*/
const char *Foo() {
return "*** Word \"%s\" on line %d is not";
return "*** Word \"%s\" on line %d is not";
}

View File

@ -10,6 +10,6 @@ static void foo(int Z) {
}
void *test() {
foo(12);
return &Y;
foo(12);
return &Y;
}

View File

@ -5,7 +5,7 @@
#include <stdlib.h>
int main(int argc, char **argv) {
char *C = (char*)alloca(argc);
strcpy(C, argv[0]);
puts(C);
char *C = (char*)alloca(argc);
strcpy(C, argv[0]);
puts(C);
}

View File

@ -3,5 +3,5 @@
#include <stdio.h>
void test() {
fprintf(stderr, "testing\n");
fprintf(stderr, "testing\n");
}

View File

@ -23,7 +23,7 @@ struct Quad {
struct SubStruct *SSP;
char c;
int y;
};
};
struct Quad GlobalQuad = { 4, {1, 2}, 0, 3, 156 };
@ -65,7 +65,7 @@ int F1(struct Quad *Q, int i) { /* Pass Q by address */
int BadFunc(float Val) {
int Result;
int Result;
if (Val > 12.345) Result = 4;
return Result; /* Test use of undefined value */
}
@ -80,14 +80,14 @@ int Func(int Param, long long Param2) {
int Result = Param;
{{{{
char c; int X;
EF1(&Result, &c, &X);
}}}
{ // c & X are duplicate names!
char c; int X;
EF1(&Result, &c, &X);
}
char c; int X;
EF1(&Result, &c, &X);
}}}
{ // c & X are duplicate names!
char c; int X;
EF1(&Result, &c, &X);
}
}
return Result;
@ -129,7 +129,7 @@ int ArrayToSum(void) {
for (i = 0; i < 100; ++i)
A[i] = i*4;
return A[A[0]]; //SumArray(A, 100);
return A[A[0]]; //SumArray(A, 100);
}
@ -141,7 +141,7 @@ int main(int argc, char *argv[]) {
ExternFunc(-1, 0, (short)argc, 2);
//func(argc, argc);
for (i = 0; i < 10; i++)
puts(argv[3]);
return 0;
@ -159,29 +159,29 @@ double MathFunc(double X, double Y, double Z,
void strcpy(char *s1, char *s2) {
while (*s1++ = *s2++);
while (*s1++ = *s2++);
}
void strcat(char *s1, char *s2) {
while (*s1++);
s1--;
while (*s1++ = *s2++);
while (*s1++);
s1--;
while (*s1++ = *s2++);
}
int strcmp(char *s1, char *s2) {
while (*s1++ == *s2++);
if (*s1 == 0) {
if (*s2 == 0) {
return 0;
} else {
return -1;
}
while (*s1++ == *s2++);
if (*s1 == 0) {
if (*s2 == 0) {
return 0;
} else {
if (*s2 == 0) {
return 1;
} else {
return (*(--s1) - *(--s2));
}
return -1;
}
} else {
if (*s2 == 0) {
return 1;
} else {
return (*(--s1) - *(--s2));
}
}
}

View File

@ -6,7 +6,7 @@ union X {
};
union X foo() {
union X A;
A.B = (void*)123;
return A;
union X A;
A.B = (void*)123;
return A;
}

View File

@ -7,16 +7,16 @@ union Q { union Q *X; };
union X {
char C;
int A, Z;
long long B;
long long B;
void *b1;
struct { int A; long long Z; } Q;
};
union X foo(union X A) {
A.C = 123;
A.A = 39249;
//A.B = (void*)123040123321;
A.B = 12301230123123LL;
A.Z = 1;
return A;
A.C = 123;
A.A = 39249;
//A.B = (void*)123040123321;
A.B = 12301230123123LL;
A.Z = 1;
return A;
}

View File

@ -3,6 +3,6 @@
int tcount;
void test(char *, const char*, int);
void foo() {
char Buf[10];
test(Buf, "n%%%d", tcount++);
char Buf[10];
test(Buf, "n%%%d", tcount++);
}

View File

@ -8,12 +8,12 @@
union X { char X; void *B; int a, b, c, d;};
union X foo() {
union X Global;
Global.B = (void*)123; /* Interesting part */
return Global;
union X Global;
Global.B = (void*)123; /* Interesting part */
return Global;
}
void main() {
union X test = foo();
printf("0x%p", test.B);
union X test = foo();
printf("0x%p", test.B);
}

View File

@ -2,5 +2,5 @@
int foo(int *A, unsigned X) {
return A[X];
return A[X];
}

View File

@ -4,5 +4,5 @@
void foo() {}
void bar() {
foo(1, 2, 3); /* Too many arguments passed */
foo(1, 2, 3); /* Too many arguments passed */
}

View File

@ -1,4 +1,4 @@
// This file can be used to see what a native C compiler is generating for a
// This file can be used to see what a native C compiler is generating for a
// variety of interesting operations.
//
// RUN: %llvmgcc -c %s -o - | llc
@ -23,4 +23,4 @@ _Bool setlt(int X, int Y) {
_Bool setgt(int X, int Y) {
return X > Y;
}

View File

@ -2,15 +2,15 @@
static int q;
void foo() {
int t = q;
q = t + 1;
int t = q;
q = t + 1;
}
int main() {
q = 0;
foo();
q = q - 1;
q = 0;
foo();
q = q - 1;
return q;
return q;
}
// This is the source that corresponds to funccall.ll