Get 'make tidy' to work rustllvm and rt again

This commit is contained in:
Brian Anderson 2011-10-21 17:35:52 -07:00
parent 93d940de54
commit 160c56e768
6 changed files with 145 additions and 145 deletions

View File

@ -82,18 +82,17 @@ check-fast: tidy \
tidy: tidy:
@$(call E, check: formatting) @$(call E, check: formatting)
$(Q)echo \ $(Q)echo \
$(filter-out $(GENERATED) $(addprefix $(S)src/, $(GENERATED)) \
$(addprefix $(S)src/, $(RUSTLLVM_LIB_CS) $(RUSTLLVM_OBJS_CS) \ $(addprefix $(S)src/, $(RUSTLLVM_LIB_CS) $(RUSTLLVM_OBJS_CS) \
$(RUSTLLVM_HDR) $(PKG_3RDPARTY) \ $(RUSTLLVM_HDR) \
$(RUNTIME_CS) $(RUNTIME_HDR) $(RUNTIME_S)) \ $(RUNTIME_CS) $(RUNTIME_HDR) $(RUNTIME_S)) \
$(S)src/etc/%, \ $(wildcard $(S)src/etc/*.py) \
$(COMPILER_CRATE) \ $(COMPILER_CRATE) \
$(COMPILER_INPUTS) \ $(COMPILER_INPUTS) \
$(STDLIB_CRATE) \ $(STDLIB_CRATE) \
$(STDLIB_INPUTS) \ $(STDLIB_INPUTS) \
$(COMPILETEST_CRATE) \ $(COMPILETEST_CRATE) \
$(COMPILETEST_INPUTS) \ $(COMPILETEST_INPUTS) \
$(ALL_TEST_INPUTS)) \ $(ALL_TEST_INPUTS) \
| xargs -n 10 python $(S)src/etc/tidy.py | xargs -n 10 python $(S)src/etc/tidy.py

View File

@ -1,76 +1,76 @@
.text .text
/* /*
Callee save registers: Callee save registers:
ebp, ebx, esi, edi ebp, ebx, esi, edi
Caller save registers: Caller save registers:
eax, ecx, edx eax, ecx, edx
*/ */
/* /*
Saves a set of registers. This is used by our implementation of Saves a set of registers. This is used by our implementation of
getcontext. getcontext.
The registers_t variable is in (%esp) The registers_t variable is in (%esp)
*/ */
// swap_registers(registers_t *oregs, registers_t *regs) // swap_registers(registers_t *oregs, registers_t *regs)
.globl swap_registers .globl swap_registers
swap_registers: swap_registers:
// save the old context // save the old context
movl 4(%esp), %eax movl 4(%esp), %eax
//movl %eax, 0(%eax) //movl %eax, 0(%eax)
movl %ebx, 4(%eax) movl %ebx, 4(%eax)
movl %ecx, 8(%eax) movl %ecx, 8(%eax)
movl %edx, 12(%eax) movl %edx, 12(%eax)
movl %ebp, 16(%eax) movl %ebp, 16(%eax)
movl %esi, 20(%eax) movl %esi, 20(%eax)
movl %edi, 24(%eax) movl %edi, 24(%eax)
//movl %cs, 32(%eax) //movl %cs, 32(%eax)
//movl %ds, 34(%eax) //movl %ds, 34(%eax)
//movl %ss, 36(%eax) //movl %ss, 36(%eax)
//movl %es, 38(%eax) //movl %es, 38(%eax)
//movl %fs, 40(%eax) //movl %fs, 40(%eax)
//movl %gs, 42(%eax) //movl %gs, 42(%eax)
// save the flags // save the flags
pushf pushf
popl %ecx popl %ecx
movl %ecx, 44(%eax) movl %ecx, 44(%eax)
// save the return address as the instruction pointer // save the return address as the instruction pointer
// and save the stack pointer of the caller // and save the stack pointer of the caller
popl %ecx popl %ecx
movl %esp, 28(%eax) movl %esp, 28(%eax)
movl %ecx, 48(%eax) movl %ecx, 48(%eax)
// restore the new context // restore the new context
movl 4(%esp), %eax movl 4(%esp), %eax
movl 4(%eax), %ebx movl 4(%eax), %ebx
// save ecx for later... // save ecx for later...
movl 12(%eax), %edx movl 12(%eax), %edx
movl 16(%eax), %ebp movl 16(%eax), %ebp
movl 20(%eax), %esi movl 20(%eax), %esi
movl 24(%eax), %edi movl 24(%eax), %edi
movl 28(%eax), %esp movl 28(%eax), %esp
// We can't actually change this... // We can't actually change this...
//movl 32(%eax), %cs //movl 32(%eax), %cs
//movl 34(%eax), %ds //movl 34(%eax), %ds
//movl 36(%eax), %ss //movl 36(%eax), %ss
//movl 38(%eax), %es //movl 38(%eax), %es
//movl 40(%eax), %fs //movl 40(%eax), %fs
//movl 42(%eax), %gs //movl 42(%eax), %gs
// restore the flags // restore the flags
movl 44(%eax), %ecx movl 44(%eax), %ecx
push %ecx push %ecx
popf popf
// ok, now we can restore ecx // ok, now we can restore ecx
movl 8(%eax), %ecx movl 8(%eax), %ecx
// Return! // Return!
jmp *48(%eax) jmp *48(%eax)

View File

@ -95,19 +95,19 @@ class irc : public shape::data<irc,shape::ptr> {
} }
void walk_fn() { void walk_fn() {
// Record an irc for the environment box, but don't descend // Record an irc for the environment box, but don't descend
// into it since it will be walked via the box's allocation // into it since it will be walked via the box's allocation
dp += sizeof(void *); // skip code pointer dp += sizeof(void *); // skip code pointer
uint8_t * box_ptr = shape::bump_dp<uint8_t *>(dp); uint8_t * box_ptr = shape::bump_dp<uint8_t *>(dp);
shape::ptr ref_count_dp(box_ptr); shape::ptr ref_count_dp(box_ptr);
maybe_record_irc(ref_count_dp); maybe_record_irc(ref_count_dp);
} }
void walk_obj() { void walk_obj() {
dp += sizeof(void *); // skip vtable dp += sizeof(void *); // skip vtable
uint8_t *box_ptr = shape::bump_dp<uint8_t *>(dp); uint8_t *box_ptr = shape::bump_dp<uint8_t *>(dp);
shape::ptr ref_count_dp(box_ptr); shape::ptr ref_count_dp(box_ptr);
maybe_record_irc(ref_count_dp); maybe_record_irc(ref_count_dp);
} }
void walk_res(const shape::rust_fn *dtor, unsigned n_params, void walk_res(const shape::rust_fn *dtor, unsigned n_params,
@ -122,7 +122,7 @@ class irc : public shape::data<irc,shape::ptr> {
void walk_subcontext(irc &sub) { sub.walk(); } void walk_subcontext(irc &sub) { sub.walk(); }
void walk_box_contents(irc &sub, shape::ptr &ref_count_dp) { void walk_box_contents(irc &sub, shape::ptr &ref_count_dp) {
maybe_record_irc(ref_count_dp); maybe_record_irc(ref_count_dp);
// Do not traverse the contents of this box; it's in the allocation // Do not traverse the contents of this box; it's in the allocation
// somewhere, so we're guaranteed to come back to it (if we haven't // somewhere, so we're guaranteed to come back to it (if we haven't
@ -133,19 +133,19 @@ class irc : public shape::data<irc,shape::ptr> {
if (!ref_count_dp) if (!ref_count_dp)
return; return;
// Bump the internal reference count of the box. // Bump the internal reference count of the box.
if (ircs.find((void *)ref_count_dp) == ircs.end()) { if (ircs.find((void *)ref_count_dp) == ircs.end()) {
LOG(task, gc, LOG(task, gc,
"setting internal reference count for %p to 1", "setting internal reference count for %p to 1",
(void *)ref_count_dp); (void *)ref_count_dp);
ircs[(void *)ref_count_dp] = 1; ircs[(void *)ref_count_dp] = 1;
} else { } else {
uintptr_t newcount = ircs[(void *)ref_count_dp] + 1; uintptr_t newcount = ircs[(void *)ref_count_dp] + 1;
LOG(task, gc, LOG(task, gc,
"bumping internal reference count for %p to %lu", "bumping internal reference count for %p to %lu",
(void *)ref_count_dp, newcount); (void *)ref_count_dp, newcount);
ircs[(void *)ref_count_dp] = newcount; ircs[(void *)ref_count_dp] = newcount;
} }
} }
void walk_struct(const uint8_t *end_sp) { void walk_struct(const uint8_t *end_sp) {
@ -191,7 +191,7 @@ irc::compute_ircs(rust_task *task, irc_map &ircs) {
const type_desc *tydesc = begin->second; const type_desc *tydesc = begin->second;
LOG(task, gc, "determining internal ref counts: %p, tydesc=%p", p, LOG(task, gc, "determining internal ref counts: %p, tydesc=%p", p,
tydesc); tydesc);
shape::arena arena; shape::arena arena;
shape::type_param *params = shape::type_param *params =
@ -237,12 +237,12 @@ find_roots(rust_task *task, irc_map &ircs, std::vector<void *> &roots) {
if (irc < ref_count) { if (irc < ref_count) {
// This allocation must be a root, because the internal reference // This allocation must be a root, because the internal reference
// count is smaller than the total reference count. // count is smaller than the total reference count.
LOG(task, gc,"root found: %p, irc %lu, ref count %lu", LOG(task, gc,"root found: %p, irc %lu, ref count %lu",
alloc, irc, ref_count); alloc, irc, ref_count);
roots.push_back(alloc); roots.push_back(alloc);
} else { } else {
LOG(task, gc, "nonroot found: %p, irc %lu, ref count %lu", LOG(task, gc, "nonroot found: %p, irc %lu, ref count %lu",
alloc, irc, ref_count); alloc, irc, ref_count);
assert(irc == ref_count && "Internal reference count must be " assert(irc == ref_count && "Internal reference count must be "
"less than or equal to the total reference count!"); "less than or equal to the total reference count!");
} }
@ -429,56 +429,56 @@ class sweep : public shape::data<sweep,shape::ptr> {
friend class shape::data<sweep,shape::ptr>; friend class shape::data<sweep,shape::ptr>;
sweep(const sweep &other, const shape::ptr &in_dp) sweep(const sweep &other, const shape::ptr &in_dp)
: shape::data<sweep,shape::ptr>(other.task, other.align, : shape::data<sweep,shape::ptr>(other.task, other.align,
other.sp, other.params, other.sp, other.params,
other.tables, in_dp) {} other.tables, in_dp) {}
sweep(const sweep &other, sweep(const sweep &other,
const uint8_t *in_sp, const uint8_t *in_sp,
const shape::type_param *in_params, const shape::type_param *in_params,
const rust_shape_tables *in_tables = NULL) const rust_shape_tables *in_tables = NULL)
: shape::data<sweep,shape::ptr>(other.task, : shape::data<sweep,shape::ptr>(other.task,
other.align, other.align,
in_sp, in_sp,
in_params, in_params,
in_tables ? in_tables : other.tables, in_tables ? in_tables : other.tables,
other.dp) {} other.dp) {}
sweep(const sweep &other, sweep(const sweep &other,
const uint8_t *in_sp, const uint8_t *in_sp,
const shape::type_param *in_params, const shape::type_param *in_params,
const rust_shape_tables *in_tables, const rust_shape_tables *in_tables,
shape::ptr in_dp) shape::ptr in_dp)
: shape::data<sweep,shape::ptr>(other.task, : shape::data<sweep,shape::ptr>(other.task,
other.align, other.align,
in_sp, in_sp,
in_params, in_params,
in_tables, in_tables,
in_dp) {} in_dp) {}
sweep(rust_task *in_task, sweep(rust_task *in_task,
bool in_align, bool in_align,
const uint8_t *in_sp, const uint8_t *in_sp,
const shape::type_param *in_params, const shape::type_param *in_params,
const rust_shape_tables *in_tables, const rust_shape_tables *in_tables,
uint8_t *in_data) uint8_t *in_data)
: shape::data<sweep,shape::ptr>(in_task, in_align, in_sp, : shape::data<sweep,shape::ptr>(in_task, in_align, in_sp,
in_params, in_tables, in_data) {} in_params, in_tables, in_data) {}
void walk_vec(bool is_pod, uint16_t sp_size) { void walk_vec(bool is_pod, uint16_t sp_size) {
void *vec = shape::get_dp<void *>(dp); void *vec = shape::get_dp<void *>(dp);
walk_vec(is_pod, get_vec_data_range(dp)); walk_vec(is_pod, get_vec_data_range(dp));
task->kernel->free(vec); task->kernel->free(vec);
} }
void walk_vec(bool is_pod, void walk_vec(bool is_pod,
const std::pair<shape::ptr,shape::ptr> &data_range) { const std::pair<shape::ptr,shape::ptr> &data_range) {
sweep sub(*this, data_range.first); sweep sub(*this, data_range.first);
shape::ptr data_end = sub.end_dp = data_range.second; shape::ptr data_end = sub.end_dp = data_range.second;
while (sub.dp < data_end) { while (sub.dp < data_end) {
sub.walk_reset(); sub.walk_reset();
sub.align = true; sub.align = true;
} }
} }
void walk_tag(shape::tag_info &tinfo, uint32_t tag_variant) { void walk_tag(shape::tag_info &tinfo, uint32_t tag_variant) {
@ -486,15 +486,15 @@ class sweep : public shape::data<sweep,shape::ptr> {
} }
void walk_box() { void walk_box() {
shape::data<sweep,shape::ptr>::walk_box_contents(); shape::data<sweep,shape::ptr>::walk_box_contents();
} }
void walk_fn() { void walk_fn() {
return; return;
} }
void walk_obj() { void walk_obj() {
return; return;
} }
void walk_res(const shape::rust_fn *dtor, unsigned n_params, void walk_res(const shape::rust_fn *dtor, unsigned n_params,
@ -509,7 +509,7 @@ class sweep : public shape::data<sweep,shape::ptr> {
void walk_subcontext(sweep &sub) { sub.walk(); } void walk_subcontext(sweep &sub) { sub.walk(); }
void walk_box_contents(sweep &sub, shape::ptr &ref_count_dp) { void walk_box_contents(sweep &sub, shape::ptr &ref_count_dp) {
return; return;
} }
void walk_struct(const uint8_t *end_sp) { void walk_struct(const uint8_t *end_sp) {
@ -522,13 +522,13 @@ class sweep : public shape::data<sweep,shape::ptr> {
void walk_variant(shape::tag_info &tinfo, uint32_t variant_id, void walk_variant(shape::tag_info &tinfo, uint32_t variant_id,
const std::pair<const uint8_t *,const uint8_t *> const std::pair<const uint8_t *,const uint8_t *>
variant_ptr_and_end) { variant_ptr_and_end) {
sweep sub(*this, variant_ptr_and_end.first, tinfo.params); sweep sub(*this, variant_ptr_and_end.first, tinfo.params);
const uint8_t *variant_end = variant_ptr_and_end.second; const uint8_t *variant_end = variant_ptr_and_end.second;
while (sub.sp < variant_end) { while (sub.sp < variant_end) {
sub.walk(); sub.walk();
align = true; align = true;
} }
} }
template<typename T> template<typename T>
@ -548,16 +548,16 @@ sweep::do_sweep(rust_task *task, const std::set<void *> &marked) {
if (marked.find(alloc) == marked.end()) { if (marked.find(alloc) == marked.end()) {
LOG(task, gc, "object is part of a cycle: %p", alloc); LOG(task, gc, "object is part of a cycle: %p", alloc);
const type_desc *tydesc = begin->second; const type_desc *tydesc = begin->second;
uint8_t *p = reinterpret_cast<uint8_t *>(alloc); uint8_t *p = reinterpret_cast<uint8_t *>(alloc);
shape::arena arena; shape::arena arena;
shape::type_param *params = shape::type_param *params =
shape::type_param::from_tydesc_and_data(tydesc, p, arena); shape::type_param::from_tydesc_and_data(tydesc, p, arena);
sweep sweep(task, true, tydesc->shape, sweep sweep(task, true, tydesc->shape,
params, tydesc->shape_tables, params, tydesc->shape_tables,
p + sizeof(uintptr_t)); p + sizeof(uintptr_t));
sweep.walk(); sweep.walk();
// FIXME: Run the destructor, *if* it's a resource. // FIXME: Run the destructor, *if* it's a resource.
task->free(alloc); task->free(alloc);
@ -570,7 +570,7 @@ sweep::do_sweep(rust_task *task, const std::set<void *> &marked) {
void void
do_cc(rust_task *task) { do_cc(rust_task *task) {
LOG(task, gc, "cc; n allocs = %lu", LOG(task, gc, "cc; n allocs = %lu",
(long unsigned int)task->local_allocs.size()); (long unsigned int)task->local_allocs.size());
irc_map ircs; irc_map ircs;
irc::compute_ircs(task, ircs); irc::compute_ircs(task, ircs);

View File

@ -1,15 +1,15 @@
//===-- RustGCPrinter.cpp - Rust garbage collection map printer -----------===// //===-- RustGCPrinter.cpp - Rust garbage collection map printer -----------===
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file is distributed under the University of Illinois Open Source // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details. // License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===
// //
// This file defines the emitter for the Rust garbage collection stack maps. // This file defines the emitter for the Rust garbage collection stack maps.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"

View File

@ -1,15 +1,15 @@
//===- RustGCStrategy.cpp - Rust garbage collection strategy ----*- C++ -*-===// //===- RustGCStrategy.cpp - Rust garbage collection strategy ----*- C++ -*-===
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file is distributed under the University of Illinois Open Source // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details. // License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===
// //
// This file defines the garbage collection strategy for Rust. // This file defines the garbage collection strategy for Rust.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===
#include "llvm/CodeGen/GCs.h" #include "llvm/CodeGen/GCs.h"
#include "llvm/CodeGen/GCStrategy.h" #include "llvm/CodeGen/GCStrategy.h"

View File

@ -1,16 +1,16 @@
//===- RustWrapper.cpp - Rust wrapper for core functions --------*- C++ -*-===// //===- RustWrapper.cpp - Rust wrapper for core functions --------*- C++ -*-===
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file is distributed under the University of Illinois Open Source // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details. // License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===
// //
// This file defines alternate interfaces to core functions that are more // This file defines alternate interfaces to core functions that are more
// readily callable by Rust's FFI. // readily callable by Rust's FFI.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===
#include "llvm/Linker.h" #include "llvm/Linker.h"
#include "llvm/PassManager.h" #include "llvm/PassManager.h"
@ -60,12 +60,13 @@ extern "C" bool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src) {
return true; return true;
} }
extern "C" void LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, extern "C" void
LLVMModuleRef M, LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
const char *triple, LLVMModuleRef M,
const char *path, const char *triple,
TargetMachine::CodeGenFileType FileType, const char *path,
CodeGenOpt::Level OptLevel) { TargetMachine::CodeGenFileType FileType,
CodeGenOpt::Level OptLevel) {
// Set compilation options. // Set compilation options.
llvm::NoFramePointerElim = true; llvm::NoFramePointerElim = true;