mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
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:
File diff suppressed because it is too large
Load Diff
@ -46,176 +46,176 @@ class StackerCompiler
|
|||||||
/// @name Constructors and Operators
|
/// @name Constructors and Operators
|
||||||
/// @{
|
/// @{
|
||||||
public:
|
public:
|
||||||
/// Default Constructor
|
/// Default Constructor
|
||||||
StackerCompiler();
|
StackerCompiler();
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~StackerCompiler();
|
~StackerCompiler();
|
||||||
private:
|
private:
|
||||||
/// Do not copy StackerCompilers
|
/// Do not copy StackerCompilers
|
||||||
StackerCompiler(const StackerCompiler&);
|
StackerCompiler(const StackerCompiler&);
|
||||||
|
|
||||||
/// Do not copy StackerCompilers.
|
/// Do not copy StackerCompilers.
|
||||||
StackerCompiler& operator=(const StackerCompiler& );
|
StackerCompiler& operator=(const StackerCompiler& );
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name High Level Interface
|
/// @name High Level Interface
|
||||||
/// @{
|
/// @{
|
||||||
public:
|
public:
|
||||||
/// @brief Compile a single file to LLVM bytecode.
|
/// @brief Compile a single file to LLVM bytecode.
|
||||||
///
|
///
|
||||||
/// To use the StackerCompiler, just create one on
|
/// To use the StackerCompiler, just create one on
|
||||||
/// the stack and call this method.
|
/// the stack and call this method.
|
||||||
Module* compile(
|
Module* compile(
|
||||||
const std::string& filename, ///< File to compile
|
const std::string& filename, ///< File to compile
|
||||||
bool echo, ///< Causes compiler to echo output
|
bool echo, ///< Causes compiler to echo output
|
||||||
unsigned optLevel, ///< Level of optimization
|
unsigned optLevel, ///< Level of optimization
|
||||||
size_t stack_size ); ///< Size of generated stack
|
size_t stack_size ); ///< Size of generated stack
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Accessors
|
/// @name Accessors
|
||||||
/// @{
|
/// @{
|
||||||
public:
|
public:
|
||||||
/// @brief Returns the name of the file being compiled.
|
/// @brief Returns the name of the file being compiled.
|
||||||
std::string& filename() { return CurFilename; }
|
std::string& filename() { return CurFilename; }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Parse Handling Methods
|
/// @name Parse Handling Methods
|
||||||
/// @{
|
/// @{
|
||||||
private:
|
private:
|
||||||
/// Allow only the parser to access these methods. No
|
/// Allow only the parser to access these methods. No
|
||||||
/// one else should call them.
|
/// one else should call them.
|
||||||
friend int Stackerparse();
|
friend int Stackerparse();
|
||||||
|
|
||||||
/// @brief Handle the start of a module
|
/// @brief Handle the start of a module
|
||||||
Module* handle_module_start();
|
Module* handle_module_start();
|
||||||
|
|
||||||
/// @brief Handle the end of a module
|
/// @brief Handle the end of a module
|
||||||
/// @param mod The module we're defining.
|
/// @param mod The module we're defining.
|
||||||
Module* handle_module_end( Module* mod );
|
Module* handle_module_end( Module* mod );
|
||||||
|
|
||||||
/// @brief Handle the start of a list of definitions
|
/// @brief Handle the start of a list of definitions
|
||||||
Module* handle_definition_list_start( );
|
Module* handle_definition_list_start( );
|
||||||
|
|
||||||
/// @brief Handle the end of a list of definitions
|
/// @brief Handle the end of a list of definitions
|
||||||
/// @param mod The module we're constructing
|
/// @param mod The module we're constructing
|
||||||
/// @param definition A definition (function) to add to the module
|
/// @param definition A definition (function) to add to the module
|
||||||
Module* handle_definition_list_end( Module* mod, Function* definition );
|
Module* handle_definition_list_end( Module* mod, Function* definition );
|
||||||
|
|
||||||
/// @brief Handle creation of the MAIN definition
|
/// @brief Handle creation of the MAIN definition
|
||||||
/// @param func The function to be used as the MAIN definition
|
/// @param func The function to be used as the MAIN definition
|
||||||
Function* handle_main_definition( Function* func );
|
Function* handle_main_definition( Function* func );
|
||||||
|
|
||||||
/// @brief Handle a forward definition
|
/// @brief Handle a forward definition
|
||||||
/// @param name The name of the definition being declared
|
/// @param name The name of the definition being declared
|
||||||
Function* handle_forward( char* name );
|
Function* handle_forward( char* name );
|
||||||
|
|
||||||
/// @brief Handle a general definition
|
/// @brief Handle a general definition
|
||||||
/// @param name The name of the definition being defined
|
/// @param name The name of the definition being defined
|
||||||
/// @param func The Function definition.
|
/// @param func The Function definition.
|
||||||
Function* handle_definition( char* name, Function* func );
|
Function* handle_definition( char* name, Function* func );
|
||||||
|
|
||||||
/// @brief Handle the start of a definition's word list
|
/// @brief Handle the start of a definition's word list
|
||||||
Function* handle_word_list_start();
|
Function* handle_word_list_start();
|
||||||
|
|
||||||
/// @brief Handle the end of a definition's word list
|
/// @brief Handle the end of a definition's word list
|
||||||
/// @param func The function to which the basic block is added
|
/// @param func The function to which the basic block is added
|
||||||
/// @param next The block to add to the function
|
/// @param next The block to add to the function
|
||||||
Function* handle_word_list_end( Function* func, BasicBlock* next );
|
Function* handle_word_list_end( Function* func, BasicBlock* next );
|
||||||
|
|
||||||
/// @brief Handle an if statement, possibly without an else
|
/// @brief Handle an if statement, possibly without an else
|
||||||
/// @brief ifTrue The block to execute if true
|
/// @brief ifTrue The block to execute if true
|
||||||
/// @brief ifFalse The optional block to execute if false
|
/// @brief ifFalse The optional block to execute if false
|
||||||
BasicBlock* handle_if( char* ifTrue, char* ifFalse = 0 );
|
BasicBlock* handle_if( char* ifTrue, char* ifFalse = 0 );
|
||||||
|
|
||||||
/// @brief Handle a while statement
|
/// @brief Handle a while statement
|
||||||
/// @brief todo The block to repeatedly execute
|
/// @brief todo The block to repeatedly execute
|
||||||
BasicBlock* handle_while( char* todo );
|
BasicBlock* handle_while( char* todo );
|
||||||
|
|
||||||
/// @brief Handle an identifier to call the identified definition
|
/// @brief Handle an identifier to call the identified definition
|
||||||
/// @param name The name of the identifier to be called.
|
/// @param name The name of the identifier to be called.
|
||||||
BasicBlock* handle_identifier( char * name );
|
BasicBlock* handle_identifier( char * name );
|
||||||
|
|
||||||
/// @brief Handle the push of a string onto the stack
|
/// @brief Handle the push of a string onto the stack
|
||||||
/// @param value The string to be pushed.
|
/// @param value The string to be pushed.
|
||||||
BasicBlock* handle_string( char * value );
|
BasicBlock* handle_string( char * value );
|
||||||
|
|
||||||
/// @brief Handle the push of an integer onto the stack.
|
/// @brief Handle the push of an integer onto the stack.
|
||||||
/// @param value The integer value to be pushed.
|
/// @param value The integer value to be pushed.
|
||||||
BasicBlock* handle_integer( const int64_t value );
|
BasicBlock* handle_integer( const int64_t value );
|
||||||
|
|
||||||
/// @brief Handle one of the reserved words (given as a token)
|
/// @brief Handle one of the reserved words (given as a token)
|
||||||
BasicBlock* handle_word( int tkn );
|
BasicBlock* handle_word( int tkn );
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Utility functions
|
/// @name Utility functions
|
||||||
/// @{
|
/// @{
|
||||||
public:
|
public:
|
||||||
/// @brief Throws an exception to indicate an error
|
/// @brief Throws an exception to indicate an error
|
||||||
/// @param message The message to be output
|
/// @param message The message to be output
|
||||||
/// @param line Override for the current line no
|
/// @param line Override for the current line no
|
||||||
static inline void ThrowException( const std::string &message,
|
static inline void ThrowException( const std::string &message,
|
||||||
int line = -1)
|
int line = -1)
|
||||||
{
|
{
|
||||||
if (line == -1) line = Stackerlineno;
|
if (line == -1) line = Stackerlineno;
|
||||||
// TODO: column number in exception
|
// TODO: column number in exception
|
||||||
throw ParseException(TheInstance->CurFilename, message, line);
|
throw ParseException(TheInstance->CurFilename, message, line);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
/// @brief Generate code to increment the stack index
|
/// @brief Generate code to increment the stack index
|
||||||
Instruction* incr_stack_index( BasicBlock* bb, Value* );
|
Instruction* incr_stack_index( BasicBlock* bb, Value* );
|
||||||
/// @brief Generate code to decrement the stack index.
|
/// @brief Generate code to decrement the stack index.
|
||||||
Instruction* decr_stack_index( BasicBlock* bb, Value* );
|
Instruction* decr_stack_index( BasicBlock* bb, Value* );
|
||||||
/// @brief Generate code to dereference the top of stack.
|
/// @brief Generate code to dereference the top of stack.
|
||||||
Instruction* get_stack_pointer( BasicBlock* bb, Value* );
|
Instruction* get_stack_pointer( BasicBlock* bb, Value* );
|
||||||
/// @brief Generate code to push any value onto the stack.
|
/// @brief Generate code to push any value onto the stack.
|
||||||
Instruction* push_value( BasicBlock* bb, Value* value );
|
Instruction* push_value( BasicBlock* bb, Value* value );
|
||||||
/// @brief Generate code to push a constant integer onto the stack.
|
/// @brief Generate code to push a constant integer onto the stack.
|
||||||
Instruction* push_integer( BasicBlock* bb, int64_t value );
|
Instruction* push_integer( BasicBlock* bb, int64_t value );
|
||||||
/// @brief Generate code to pop an integer off the stack.
|
/// @brief Generate code to pop an integer off the stack.
|
||||||
Instruction* pop_integer( BasicBlock* bb );
|
Instruction* pop_integer( BasicBlock* bb );
|
||||||
/// @brief Generate code to push a string pointer onto the stack.
|
/// @brief Generate code to push a string pointer onto the stack.
|
||||||
Instruction* push_string( BasicBlock* bb, const char* value );
|
Instruction* push_string( BasicBlock* bb, const char* value );
|
||||||
/// @brief Generate code to pop a string pointer off the stack.
|
/// @brief Generate code to pop a string pointer off the stack.
|
||||||
Instruction* pop_string( BasicBlock* bb );
|
Instruction* pop_string( BasicBlock* bb );
|
||||||
/// @brief Generate code to get the top stack element.
|
/// @brief Generate code to get the top stack element.
|
||||||
Instruction* stack_top( BasicBlock* bb, Value* index );
|
Instruction* stack_top( BasicBlock* bb, Value* index );
|
||||||
/// @brief Generate code to get the top stack element as a string.
|
/// @brief Generate code to get the top stack element as a string.
|
||||||
Instruction* stack_top_string( BasicBlock* bb, Value* index );
|
Instruction* stack_top_string( BasicBlock* bb, Value* index );
|
||||||
/// @brief Generate code to replace the top element of the stack.
|
/// @brief Generate code to replace the top element of the stack.
|
||||||
Instruction* replace_top( BasicBlock* bb, Value* new_top, Value* index);
|
Instruction* replace_top( BasicBlock* bb, Value* new_top, Value* index);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Data Members (used during parsing)
|
/// @name Data Members (used during parsing)
|
||||||
/// @{
|
/// @{
|
||||||
public:
|
public:
|
||||||
static StackerCompiler* TheInstance; ///< The instance for the parser
|
static StackerCompiler* TheInstance; ///< The instance for the parser
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string CurFilename; ///< Current file name
|
std::string CurFilename; ///< Current file name
|
||||||
Module* TheModule; ///< Module instance we'll build
|
Module* TheModule; ///< Module instance we'll build
|
||||||
Function* TheFunction; ///< Function we're building
|
Function* TheFunction; ///< Function we're building
|
||||||
FunctionType* DefinitionType; ///< FT for Definitions
|
FunctionType* DefinitionType; ///< FT for Definitions
|
||||||
GlobalVariable* TheStack; ///< For referencing _stack_
|
GlobalVariable* TheStack; ///< For referencing _stack_
|
||||||
GlobalVariable* TheIndex; ///< For referencing _index_
|
GlobalVariable* TheIndex; ///< For referencing _index_
|
||||||
Function* TheScanf; ///< External input function
|
Function* TheScanf; ///< External input function
|
||||||
Function* ThePrintf; ///< External output function
|
Function* ThePrintf; ///< External output function
|
||||||
Function* TheExit; ///< External exit function
|
Function* TheExit; ///< External exit function
|
||||||
GlobalVariable* StrFormat; ///< Format for strings
|
GlobalVariable* StrFormat; ///< Format for strings
|
||||||
GlobalVariable* NumFormat; ///< Format for numbers
|
GlobalVariable* NumFormat; ///< Format for numbers
|
||||||
GlobalVariable* ChrFormat; ///< Format for chars
|
GlobalVariable* ChrFormat; ///< Format for chars
|
||||||
GlobalVariable* InStrFormat; ///< Format for input strings
|
GlobalVariable* InStrFormat; ///< Format for input strings
|
||||||
GlobalVariable* InNumFormat; ///< Format for input numbers
|
GlobalVariable* InNumFormat; ///< Format for input numbers
|
||||||
GlobalVariable* InChrFormat; ///< Format for input chars
|
GlobalVariable* InChrFormat; ///< Format for input chars
|
||||||
ConstantInt* Zero; ///< long constant 0
|
ConstantInt* Zero; ///< long constant 0
|
||||||
ConstantInt* One; ///< long constant 1
|
ConstantInt* One; ///< long constant 1
|
||||||
ConstantInt* Two; ///< long constant 2
|
ConstantInt* Two; ///< long constant 2
|
||||||
ConstantInt* Three; ///< long constant 3
|
ConstantInt* Three; ///< long constant 3
|
||||||
ConstantInt* Four; ///< long constant 4
|
ConstantInt* Four; ///< long constant 4
|
||||||
ConstantInt* Five; ///< long constant 5
|
ConstantInt* Five; ///< long constant 5
|
||||||
std::vector<Value*> no_arguments; ///< no arguments for Stacker
|
std::vector<Value*> no_arguments; ///< no arguments for Stacker
|
||||||
bool echo; ///< Echo flag
|
bool echo; ///< Echo flag
|
||||||
size_t stack_size; ///< Size of stack to gen.
|
size_t stack_size; ///< Size of stack to gen.
|
||||||
ArrayType* stack_type; ///< The type of the stack
|
ArrayType* stack_type; ///< The type of the stack
|
||||||
/// @}
|
/// @}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
//===-- stacker_rt.c - Runtime Support For Stacker Compiler -----*- C++ -*-===//
|
//===-- stacker_rt.c - Runtime Support For Stacker Compiler -----*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
// This file was developed by Reid Spencer and donated to the LLVM research
|
// This file was developed by Reid Spencer and donated to the LLVM research
|
||||||
// group and is distributed under the University of Illinois Open Source
|
// group and is distributed under the University of Illinois Open Source
|
||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// This file defines a stack dumping function that can be used for debugging.
|
// This file defines a stack dumping function that can be used for debugging.
|
||||||
@ -33,7 +33,7 @@ _stacker_dump_stack_()
|
|||||||
printf("Stack Dump:\n");
|
printf("Stack Dump:\n");
|
||||||
for (i = _index_; i > 0; i-- )
|
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
|
// so that they get popped in the order presented
|
||||||
while ( a > 0 )
|
while ( a > 0 )
|
||||||
{
|
{
|
||||||
if ( isdigit( (int) argv[--a][0] ) )
|
if ( isdigit( (int) argv[--a][0] ) )
|
||||||
{
|
{
|
||||||
_stack_[_index_++] = atoll( argv[a] );
|
_stack_[_index_++] = atoll( argv[a] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_stack_[_index_++] = (int64_t) (intptr_t) argv[a];
|
_stack_[_index_++] = (int64_t) (intptr_t) argv[a];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the argument count on the stack
|
// Put the argument count on the stack
|
||||||
@ -68,6 +68,6 @@ main ( int argc, char** argv )
|
|||||||
|
|
||||||
// Return last item on the stack
|
// Return last item on the stack
|
||||||
if ( _index_ >= 0 )
|
if ( _index_ >= 0 )
|
||||||
return _stack_[_index_];
|
return _stack_[_index_];
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -34,14 +34,14 @@ InputFilename(cl::Positional, cl::desc("<input .st file>"), cl::init("-"));
|
|||||||
|
|
||||||
static cl::opt<std::string>
|
static cl::opt<std::string>
|
||||||
OutputFilename("o", cl::desc("Override output filename"),
|
OutputFilename("o", cl::desc("Override output filename"),
|
||||||
cl::value_desc("filename"));
|
cl::value_desc("filename"));
|
||||||
|
|
||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
Force("f", cl::desc("Overwrite output files"));
|
Force("f", cl::desc("Overwrite output files"));
|
||||||
|
|
||||||
static cl::opt<uint32_t>
|
static cl::opt<uint32_t>
|
||||||
StackSize("s", cl::desc("Specify program maximum stack size"),
|
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>
|
static cl::opt<bool>
|
||||||
DumpAsm("d", cl::desc("Print LLVM Assembly as parsed"), cl::Hidden);
|
DumpAsm("d", cl::desc("Print LLVM Assembly as parsed"), cl::Hidden);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* File: sample.h
|
* File: sample.h
|
||||||
*
|
*
|
||||||
* This is a sample header file that is global to the entire project.
|
* This is a sample header file that is global to the entire project.
|
||||||
* It is located here so that everyone will find it.
|
* It is located here so that everyone will find it.
|
||||||
*/
|
*/
|
||||||
extern int compute_sample (int a);
|
extern int compute_sample (int a);
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* File: sample.c
|
* File: sample.c
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This is a sample source file for a library. It helps to demonstrate
|
* 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,
|
* how to setup a project that uses the LLVM build system, header files,
|
||||||
* and libraries.
|
* and libraries.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -19,6 +19,6 @@
|
|||||||
int
|
int
|
||||||
compute_sample (int a)
|
compute_sample (int a)
|
||||||
{
|
{
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
int
|
int
|
||||||
main (int argc, char ** argv)
|
main (int argc, char ** argv)
|
||||||
{
|
{
|
||||||
printf ("%d\n", compute_sample (5));
|
printf ("%d\n", compute_sample (5));
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
struct duration {
|
struct duration {
|
||||||
duration operator/=(int c) {
|
duration operator/=(int c) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void a000090() {
|
void a000090() {
|
||||||
duration() /= 1;
|
duration() /= 1;
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
// was mistakenly "thinking" that 'foo' took a structure by component.
|
// was mistakenly "thinking" that 'foo' took a structure by component.
|
||||||
|
|
||||||
struct C {
|
struct C {
|
||||||
int A, B;
|
int A, B;
|
||||||
~C() {}
|
~C() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
void foo(C b);
|
void foo(C b);
|
||||||
|
|
||||||
void test(C *P) {
|
void test(C *P) {
|
||||||
foo(*P);
|
foo(*P);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
// RUN: %llvmgcc -S %s -o - | llvm-as -f -o /dev/null
|
// 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
|
* names should be in distinct namespaces
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct foo {
|
typedef struct foo {
|
||||||
int X, Y;
|
int X, Y;
|
||||||
} FOO;
|
} FOO;
|
||||||
|
|
||||||
static FOO foo[100];
|
static FOO foo[100];
|
||||||
|
|
||||||
int test() {
|
int test() {
|
||||||
return foo[4].Y;
|
return foo[4].Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
/* GCC wasn't handling 64 bit constants right fixed */
|
/* GCC wasn't handling 64 bit constants right fixed */
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
long long Var = 123455678902ll;
|
long long Var = 123455678902ll;
|
||||||
printf("%lld\n", Var);
|
printf("%lld\n", Var);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int test(char *X) {
|
int test(char *X) {
|
||||||
/* LLVM-GCC used to emit:
|
/* LLVM-GCC used to emit:
|
||||||
%.LC0 = internal global [3 x sbyte] c"\1F\FFFFFF8B\00"
|
%.LC0 = internal global [3 x sbyte] c"\1F\FFFFFF8B\00"
|
||||||
*/
|
*/
|
||||||
return strcmp(X, "\037\213");
|
return strcmp(X, "\037\213");
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// RUN: %llvmgcc -S %s -o - | llvm-as -f -o /dev/null
|
// 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:
|
* get emitted:
|
||||||
* %.LC1 = internal global [32 x sbyte] c"*** Word "%s" on line %d is not\00"
|
* %.LC1 = internal global [32 x sbyte] c"*** Word "%s" on line %d is not\00"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *Foo() {
|
const char *Foo() {
|
||||||
return "*** Word \"%s\" on line %d is not";
|
return "*** Word \"%s\" on line %d is not";
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,6 @@ static void foo(int Z) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *test() {
|
void *test() {
|
||||||
foo(12);
|
foo(12);
|
||||||
return &Y;
|
return &Y;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
char *C = (char*)alloca(argc);
|
char *C = (char*)alloca(argc);
|
||||||
strcpy(C, argv[0]);
|
strcpy(C, argv[0]);
|
||||||
puts(C);
|
puts(C);
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void test() {
|
void test() {
|
||||||
fprintf(stderr, "testing\n");
|
fprintf(stderr, "testing\n");
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ struct Quad {
|
|||||||
struct SubStruct *SSP;
|
struct SubStruct *SSP;
|
||||||
char c;
|
char c;
|
||||||
int y;
|
int y;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Quad GlobalQuad = { 4, {1, 2}, 0, 3, 156 };
|
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 BadFunc(float Val) {
|
||||||
int Result;
|
int Result;
|
||||||
if (Val > 12.345) Result = 4;
|
if (Val > 12.345) Result = 4;
|
||||||
return Result; /* Test use of undefined value */
|
return Result; /* Test use of undefined value */
|
||||||
}
|
}
|
||||||
@ -80,14 +80,14 @@ int Func(int Param, long long Param2) {
|
|||||||
int Result = Param;
|
int Result = Param;
|
||||||
|
|
||||||
{{{{
|
{{{{
|
||||||
char c; int X;
|
char c; int X;
|
||||||
EF1(&Result, &c, &X);
|
EF1(&Result, &c, &X);
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
{ // c & X are duplicate names!
|
{ // c & X are duplicate names!
|
||||||
char c; int X;
|
char c; int X;
|
||||||
EF1(&Result, &c, &X);
|
EF1(&Result, &c, &X);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return Result;
|
return Result;
|
||||||
@ -129,7 +129,7 @@ int ArrayToSum(void) {
|
|||||||
for (i = 0; i < 100; ++i)
|
for (i = 0; i < 100; ++i)
|
||||||
A[i] = i*4;
|
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);
|
ExternFunc(-1, 0, (short)argc, 2);
|
||||||
//func(argc, argc);
|
//func(argc, argc);
|
||||||
|
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
puts(argv[3]);
|
puts(argv[3]);
|
||||||
return 0;
|
return 0;
|
||||||
@ -159,29 +159,29 @@ double MathFunc(double X, double Y, double Z,
|
|||||||
|
|
||||||
|
|
||||||
void strcpy(char *s1, char *s2) {
|
void strcpy(char *s1, char *s2) {
|
||||||
while (*s1++ = *s2++);
|
while (*s1++ = *s2++);
|
||||||
}
|
}
|
||||||
|
|
||||||
void strcat(char *s1, char *s2) {
|
void strcat(char *s1, char *s2) {
|
||||||
while (*s1++);
|
while (*s1++);
|
||||||
s1--;
|
s1--;
|
||||||
while (*s1++ = *s2++);
|
while (*s1++ = *s2++);
|
||||||
}
|
}
|
||||||
|
|
||||||
int strcmp(char *s1, char *s2) {
|
int strcmp(char *s1, char *s2) {
|
||||||
while (*s1++ == *s2++);
|
while (*s1++ == *s2++);
|
||||||
if (*s1 == 0) {
|
if (*s1 == 0) {
|
||||||
if (*s2 == 0) {
|
if (*s2 == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (*s2 == 0) {
|
return -1;
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return (*(--s1) - *(--s2));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (*s2 == 0) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return (*(--s1) - *(--s2));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ union X {
|
|||||||
};
|
};
|
||||||
|
|
||||||
union X foo() {
|
union X foo() {
|
||||||
union X A;
|
union X A;
|
||||||
A.B = (void*)123;
|
A.B = (void*)123;
|
||||||
return A;
|
return A;
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,16 @@ union Q { union Q *X; };
|
|||||||
union X {
|
union X {
|
||||||
char C;
|
char C;
|
||||||
int A, Z;
|
int A, Z;
|
||||||
long long B;
|
long long B;
|
||||||
void *b1;
|
void *b1;
|
||||||
struct { int A; long long Z; } Q;
|
struct { int A; long long Z; } Q;
|
||||||
};
|
};
|
||||||
|
|
||||||
union X foo(union X A) {
|
union X foo(union X A) {
|
||||||
A.C = 123;
|
A.C = 123;
|
||||||
A.A = 39249;
|
A.A = 39249;
|
||||||
//A.B = (void*)123040123321;
|
//A.B = (void*)123040123321;
|
||||||
A.B = 12301230123123LL;
|
A.B = 12301230123123LL;
|
||||||
A.Z = 1;
|
A.Z = 1;
|
||||||
return A;
|
return A;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
int tcount;
|
int tcount;
|
||||||
void test(char *, const char*, int);
|
void test(char *, const char*, int);
|
||||||
void foo() {
|
void foo() {
|
||||||
char Buf[10];
|
char Buf[10];
|
||||||
test(Buf, "n%%%d", tcount++);
|
test(Buf, "n%%%d", tcount++);
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
union X { char X; void *B; int a, b, c, d;};
|
union X { char X; void *B; int a, b, c, d;};
|
||||||
|
|
||||||
union X foo() {
|
union X foo() {
|
||||||
union X Global;
|
union X Global;
|
||||||
Global.B = (void*)123; /* Interesting part */
|
Global.B = (void*)123; /* Interesting part */
|
||||||
return Global;
|
return Global;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
union X test = foo();
|
union X test = foo();
|
||||||
printf("0x%p", test.B);
|
printf("0x%p", test.B);
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
|
|
||||||
int foo(int *A, unsigned X) {
|
int foo(int *A, unsigned X) {
|
||||||
return A[X];
|
return A[X];
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
void foo() {}
|
void foo() {}
|
||||||
|
|
||||||
void bar() {
|
void bar() {
|
||||||
foo(1, 2, 3); /* Too many arguments passed */
|
foo(1, 2, 3); /* Too many arguments passed */
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// variety of interesting operations.
|
||||||
//
|
//
|
||||||
// RUN: %llvmgcc -c %s -o - | llc
|
// RUN: %llvmgcc -c %s -o - | llc
|
||||||
@ -23,4 +23,4 @@ _Bool setlt(int X, int Y) {
|
|||||||
_Bool setgt(int X, int Y) {
|
_Bool setgt(int X, int Y) {
|
||||||
return X > Y;
|
return X > Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
static int q;
|
static int q;
|
||||||
|
|
||||||
void foo() {
|
void foo() {
|
||||||
int t = q;
|
int t = q;
|
||||||
q = t + 1;
|
q = t + 1;
|
||||||
}
|
}
|
||||||
int main() {
|
int main() {
|
||||||
q = 0;
|
q = 0;
|
||||||
foo();
|
foo();
|
||||||
q = q - 1;
|
q = q - 1;
|
||||||
|
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the source that corresponds to funccall.ll
|
// This is the source that corresponds to funccall.ll
|
||||||
|
Reference in New Issue
Block a user