Skip to content

Commit

Permalink
License file and start branches
Browse files Browse the repository at this point in the history
  • Loading branch information
chorman0773 committed Feb 14, 2022
1 parent 3efbfd6 commit 13924fd
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 14 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Connor Horman <[email protected]>
30 changes: 30 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright (c) 2021-2022 Lightning Creations

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Subject to the terms and conditions of this license, each copyright holder and contributor hereby grants to those receiving rights under this license a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except for failure to satisfy the conditions of this license) patent license to make,
have made, use, offer to sell, sell, import, and otherwise transfer this software, where such license applies only to those patent claims,
already acquired or hereafter acquired, licensable by such copyright holder or contributor that are necessarily infringed by:

(a) their Contribution(s) (the licensed copyrights of copyright holders and non-copyrightable additions of contributors, in source or binary form) alone; or

(b) combination of their Contribution(s) with the work of authorship to which such Contribution(s) was added by such copyright holder or contributor,
if, at the time the Contribution is added, such addition causes such combination to be necessarily infringed.
The patent license shall not apply to any other combinations which include the Contribution.

Except as expressly stated above, no rights or licenses from any copyright holder or contributor is granted under this license,
whether expressly, by implication, estoppel or otherwise.

DISCLAIMER

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 changes: 21 additions & 13 deletions Makefile.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,26 @@ stage2_CC = @stage2_CC@
stage2_CFLAGS = @stage2_CFLAGS@
stage2_RUSTFLAGS = @stage2_RUSTFLAGS@

main = lccc xlang
languages = @languages@
codegens = @codegens@


##
# Do not Edit past this point

.DEFAULT_GOAL = all

stage0_builddir = ${builddir}
stage0_builddir = ${builddir}/build
stage0_abs_builddir = ${abs_builddir}/build

stage1_builddir = ${builddir}/
stage1_abs_builddir = ${abs_builddir}/

vendor_STEM = vendor
vendor_SRCDIR = ${srcdir}/vendor
vendor_STAGE0_GOAL = all
vendor_STAGE1_GOAL = all
vendor_STAGE2_GOAL =
vendor_DEPS =


steps = vendor @steps@

[+ foreach main +]

Expand Down Expand Up @@ -139,22 +138,31 @@ vendor_DEPS =

[+name+]_STEM = [+subdir+]
[+name+]_STAGE0_GOAL = all
[+name+]_STAGE1_GOAL = all
[+name+]_STAGE1_GOAL = @stage1_libs@ all
[+name+]_STAGE2_GOAL = libraries
[+name+]_DEPS = vendor [+deps+]

[+ endfor +]

COMMON_EXPORTS = export INSTALL=$(INSTALL);
COMMON_EXPORTS = export INSTALL=$(INSTALL)

STAGE0_EXPORTS = CC=$(stage0_CC); CFLAGS=$(stage0_CFLAGS); RUSTC=$(stage0_RUSTC); RUSTFLAGS=$(stage0_RUSTFLAGS); \
CC_FOR_BUILD=$(stage0_CC); CFLAGS_FOR_BUILD=$(stage0_CFLAGS); RUSTC=$(stage0_RUSTC); RUSTFLAGS=$(stage0_RUSTFLAGS);
STAGE0_EXPORTS = $(COMMON_EXPORTS); export CC=$(stage0_CC); export CFLAGS=$(stage0_CFLAGS); export RUSTC=$(stage0_RUSTC); export RUSTFLAGS=$(stage0_RUSTFLAGS); \
export CC_FOR_BUILD=$(stage0_CC); export CFLAGS_FOR_BUILD=$(stage0_CFLAGS); export RUSTC_FOR_BUILD=$(stage0_RUSTC); export RUSTFLAGS_FOR_BUILD=$(stage0_RUSTFLAGS)

STAGE0_CONFIGURE = --prefix=$(prefix) --exec-prefix=$(exec_prefix) --bindir=$(bindir) --sbindir=$(sbindir) --libdir=$(libdir) --libexecdir=$(libexecdir)

[+ define gen_goals +]

.PHONY: $([+name+]_[+builddir+])/configure $([+name+]_[+builddir+])/
.PHONY: [+name+]_[+builddir+]-configure [+name+]_[+builddir+]/all [+name+]_[+builddir+]/install [+name+]_[+builddir+]/install-strip [+name+]_[+builddir+]/clean [+name+]_[+builddir+]/libraries

[+name+]_[+builddir+]-configure: [+srcdir+]/configure $(foreach dep,[+deps], $($(dep)_DEPS)_[+builddir+]/stamp)
@+$(MKDIR_P) $([+name+]_[+builddir+]); cd [+builddir+]; [+exports+]; [+extra_exports+]; ../[+srcdir+]/configure [+configure+] [+extra_configure+]

$([+name+]_[+builddir+])/:
@+[+exports+]; [+extra_exports+]; $(MAKE) [+name+]_[+builddir+]-configure

$([+name+]_[+builddir+])/%: $([+name+]_[+builddir+])/ $(foreach dep,[+deps], $($(dep)_DEPS)_[+builddir+]/stamp)
@+[+exports+]; [+extra_exports+]; $(MAKE) -C [+name+]_[+builddir+] $*

${[+builddir+]/configure: [+srcdir+]/configure
@+$(MKDIR_P) [+builddir+]; cd [+builddir+]; [+exports+]; [+extra_exports+];

[+ enddef +]
1 change: 1 addition & 0 deletions codegen-x86/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ impl FunctionRawCodegen for X86CodegenState {
VStackValue::Trapped => {}
VStackValue::AggregatePieced(_, _) => todo!(),
VStackValue::OpaqueAggregate(_, _) => todo!(),
VStackValue::CompareResult(_, _) => todo!(),
}
}

Expand Down
13 changes: 13 additions & 0 deletions lccc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ fn main() {
TakesArg::Never,
true
),
ArgSpec::new(
"version",
xlang::vec!["version"],
xlang::vec!['V'],
TakesArg::Never,
true
)
];

let (args, files) = parse_args(&argspecs);
Expand Down Expand Up @@ -110,6 +117,12 @@ fn main() {
None => unreachable!(),
};
}
"version" => {
println!("lccc {}", std::env!("CARGO_PKG_VERSION"));
println!("Copyright (C) 2021-2022 Lightning Creations");
println!("Released under the Terms of the 2 Clause BSD license, with explicit patent grant");
return;
}
_ => panic!(),
}
}
Expand Down
3 changes: 3 additions & 0 deletions xlang/xlang_backend/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ pub enum VStackValue<Loc: ValLocation> {
/// Represents an aggregate which is stored in memory
OpaqueAggregate(Type, Loc),

/// The result of the `cmp` instruction
CompareResult(Box<VStackValue<Loc>>, Box<VStackValue<Loc>>),

/// Placeholder for a value that's already caused a `ud2`
Trapped,
}
Expand Down
34 changes: 33 additions & 1 deletion xlang/xlang_backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ impl<F: FunctionRawCodegen> FunctionCodegen<F> {
}
}

/// Clears the expression stack
pub fn clear_stack(&mut self) {
self.vstack.clear()
}

/// Writes an expression in linear order into the codegen
pub fn write_expr(&mut self, expr: &Expr) {
match expr {
Expand Down Expand Up @@ -255,6 +260,14 @@ impl<F: FunctionRawCodegen> FunctionCodegen<F> {
}
}
}
Expr::BinaryOp(BinaryOp::Cmp) => {
let [val1, val2] = [
self.vstack.pop_back().unwrap(),
self.vstack.pop_back().unwrap(),
];
self.vstack
.push_back(VStackValue::CompareResult(Box::new(val1), Box::new(val2)))
}
Expr::BinaryOp(op) => todo!("binary op {:?}", op),
Expr::UnaryOp(op) => todo!("unary op {:?}", op),
Expr::CallFunction(ty) => {
Expand Down Expand Up @@ -286,7 +299,25 @@ impl<F: FunctionRawCodegen> FunctionCodegen<F> {
v => panic!("invalid value {:?}", v),
}
}
Expr::Branch { .. } => {}
Expr::Branch { cond, target } => {
match cond {
BranchCondition::Always => {
let locs = self.targets[target].clone();
let vals = self.pop_values(locs.len()).unwrap();
for (val, (loc, _)) in vals.into_iter().zip(locs) {
self.inner.move_value(val, loc); // This will break if the branch target uses any values rn.
}
self.clear_stack()
}
BranchCondition::Less => todo!(),
BranchCondition::LessEqual => todo!(),
BranchCondition::Equal => todo!(),
BranchCondition::NotEqual => todo!(),
BranchCondition::Greater => todo!(),
BranchCondition::GreaterEqual => todo!(),
BranchCondition::Never => {}
}
}
Expr::Convert(_, ty) => {
let val = self.vstack.pop_back().unwrap();
match (val, ty) {
Expand Down Expand Up @@ -382,6 +413,7 @@ impl<F: FunctionRawCodegen> FunctionCodegen<F> {
self.targets.insert(*num, values);
}
}

for item in &block.items {
self.diverged = false;
match item {
Expand Down

0 comments on commit 13924fd

Please sign in to comment.