Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGrulich committed Jun 15, 2024
1 parent 2f32bca commit cdc2caa
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 103 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/sanitizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Sanitizer Nautilus
run-name: ${{ github.actor }} builds Nautilus
on: [ push ]
jobs:
build-test:
runs-on: ${{matrix.os}}
name: Build on ${{ matrix.os }} with ${{ matrix.cc }} ${{ matrix.flags }}
strategy:
fail-fast: false
matrix:
include:
- os: 'ubuntu-24.04'
cc: 'clang-18'
cxx: 'clang++-18'
flags: '-DENABLE_ADDRESS_SANITIZER=ON'
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: get cmake
uses: lukka/get-cmake@latest
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.cc }}
- name: cmake
shell: bash
run: |
cmake -DCMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache ${{ matrix.flags }} -G Ninja -S . -B .
- name: build
shell: bash
run: |
cmake --build . --target all
- name: test
shell: bash
run: |
cd nautilus && ctest --test-dir=nautilus --output-on-failure
146 changes: 49 additions & 97 deletions nautilus/include/nautilus/val.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,49 +86,43 @@ tracing::value_ref getState(T&& value) {

} // namespace details

template <typename ValueType>
class base_val {
public:
#ifdef ENABLE_TRACING
const tracing::value_ref state;
base_val() : state(tracing::traceConstant(0)) {};
base_val(ValueType value) : state(tracing::traceConstant(value)), value(value) {};
base_val(tracing::value_ref& tc) : state(tc), value() {};
base_val(const base_val<ValueType>& other) : state(tracing::traceCopy(other.state)), value(other.value) {};
base_val(const base_val<ValueType>&& other) noexcept : state(other.state), value(other.value) {};
#else
base_val() {};
base_val(ValueType value) : value(value) {};
#endif
protected:
template <class T>
friend T details::getRawValue(val<T>& val);
ValueType value;
};

// val substitution for all arithmetic value type, integer, float, bool
template <is_arithmetic ValueType>
class val<ValueType> {
class val<ValueType> : public base_val<ValueType> {
public:
using raw_type = ValueType;
using basic_type = ValueType;
using base_val<ValueType>::base_val;

#ifdef ENABLE_TRACING
const tracing::value_ref state;
inline val() : state(tracing::traceConstant(0)) {};
inline val(ValueType value) : state(tracing::traceConstant(value)), value(value) {};
// copy constructor
inline val(const val<ValueType>& other) : state(tracing::traceCopy(other.state)), value(other.value) {};
inline val(const val<ValueType>& other) : base_val<ValueType>(other) {};
// move constructor
inline val(const val<ValueType>&& other) noexcept : state(other.state), value(other.value) {};
inline val(tracing::value_ref& tc) : state(tc), value() {};
#else
val() {};
val(ValueType value) : value(value) {};
// copy constructor
val(const val<ValueType>& other) : value(other.value) {};
// move constructor
val(const val<ValueType>&& other) : value(other.value) {};
#endif

~val() {

#ifdef ENABLE_TRACING
if (tracing::inTracer()) {

// tracing::getVarRefMap()[state.ref]--;
// if (tracing::getVarRefMap()[state.ref] == 0) {
// tracing::traceValueDestruction(state);
// std::cout << "destructor " << state << " - " << tag << std::endl;
// }
}
#endif
}
inline val(const val<ValueType>&& other) noexcept : base_val<ValueType>(std::move(other)) {};

val<ValueType>& operator=(const val<ValueType>& other) {
#ifdef ENABLE_TRACING
if (tracing::inTracer()) {
tracing::traceAssignment(state, other.state, tracing::to_type<ValueType>());
tracing::traceAssignment(this->state, other.state, tracing::to_type<ValueType>());
}
#endif
this->value = other.value;
Expand All @@ -141,11 +135,11 @@ class val<ValueType> {
// cast
if SHOULD_TRACE () {
#ifdef ENABLE_TRACING
auto resultRef = tracing::traceCast(state, tracing::to_type<OtherType>());
auto resultRef = tracing::traceCast(this->state, tracing::to_type<OtherType>());
return val<OtherType>(resultRef);
#endif
}
return val<OtherType>(value);
return val<OtherType>(this->value);
}

const val<ValueType>& operator++() {
Expand Down Expand Up @@ -186,9 +180,6 @@ class val<ValueType> {
}

private:
friend ValueType details::getRawValue<ValueType>(val<ValueType>& left);
ValueType value;

template <is_arithmetic LHS, is_arithmetic RHS>
friend COMMON_RETURN_TYPE mul(val<LHS>& left, val<RHS>& right);

Expand Down Expand Up @@ -245,65 +236,41 @@ class val<ValueType> {
};

template <>
class val<bool> {
class val<bool> : public base_val<bool> {
public:
using raw_type = bool;
using basic_type = bool;

#ifdef ENABLE_TRACING

tracing::value_ref state;
val() : state(tracing::traceConstant(0)), value(false) {};
val(bool value) : state(tracing::traceConstant(value)), value(value) {};
// copy constructor
val(const val<bool>& other) : state(tracing::traceCopy(other.state)), value(other.value) {};
// move constructor
val(const val<bool>&& other) noexcept : state(other.state), value(other.value) {};
val(tracing::value_ref& tc) : state(tc) {};

#else
val() {};
val(bool value) : value(value) {};
using base_val<bool>::base_val;
// copy constructor
val(const val<bool>& other) : value(other.value) {};
inline val(const val<bool>& other) : base_val<bool>(other) {};
// move constructor
val(const val<bool>&& other) : value(other.value) {};
#endif

~val() {
if SHOULD_TRACE () {

// tracing::getVarRefMap()[state.ref]--;
// if (tracing::getVarRefMap()[state.ref] == 0) {
// tracing::traceValueDestruction(state);
// std::cout << "destructor " << state << " - " << tag << std::endl;
// }
}
}
inline val(const val<bool>&& other) noexcept : base_val<bool>(std::move(other)) {};

val<bool>& operator=(const val<bool>& other) {

if SHOULD_TRACE () {
#ifdef ENABLE_TRACING
tracing::traceAssignment(state, other.state, tracing::to_type<bool>());
#endif
if (tracing::inTracer()) {
tracing::traceAssignment( this->state, other.state, tracing::to_type<bool>());
}
#endif

this->value = other.value;
return *this;
};

operator bool() const {
if SHOULD_TRACE () {
#ifdef ENABLE_TRACING
auto ref = state;
operator bool() const {
if (tracing::inTracer()) {
auto ref = this->state;
return tracing::traceBool(ref);
#endif
}
return value;
return this->value;
}
#else
operator bool() const {
return this->value;
}
#endif

bool value;
};

template <class T>
Expand Down Expand Up @@ -356,22 +323,6 @@ auto&& cast_value(LeftType&& value) {

namespace details {

#ifdef ENABLE_TRACING
#define TRAC_BINARY_OP(OP) \
if (tracing::inTracer()) { \
auto tc = tracing::traceBinaryOp<tracing::OP, commonType>(lValue.state, rValue.state); \
return val<commonType>(tc); \
}

#define TRAC_BINARY_OP_DIRECT(OP) \
if (tracing::inTracer()) { \
auto tc = tracing::traceBinaryOp<tracing::OP, commonType>(left.state, right.state); \
return val<commonType>(tc); \
}
#else
#define TRAC_OP(OP)
#endif

#ifdef ENABLE_TRACING
#define TRAC_LOGICAL_BINARY_OP(OP) \
if (tracing::inTracer()) { \
Expand All @@ -389,7 +340,8 @@ namespace details {
auto&& lValue = cast_value<LHS, commonType>(std::forward<LHS>(left)); \
auto&& rValue = cast_value<RHS, commonType>(std::forward<RHS>(right)); \
if SHOULD_TRACE () { \
auto tc = tracing::traceBinaryOp<tracing::OP_TRACE, commonType>(details::getState(lValue), details::getState(rValue)); \
auto tc = tracing::traceBinaryOp<tracing::OP_TRACE, commonType>(details::getState(lValue), \
details::getState(rValue)); \
return RES_TYPE(tc); \
} \
return RES_TYPE(getRawValue(lValue) OP getRawValue(rValue)); \
Expand Down Expand Up @@ -437,7 +389,7 @@ val<LHS> inline neg(val<LHS>& val) {
}

template <typename LHS>
LHS inline getRawValue(val<LHS>& val) {
LHS getRawValue(val<LHS>& val) {
return val.value;
}

Expand Down Expand Up @@ -567,7 +519,7 @@ val<bool> inline lOr(val<bool>& left, val<bool>& right) {
return val<bool> {tc};
}
#endif
return left.value || right.value;
return getRawValue(left) || getRawValue(right);
}

val<bool> inline lAnd(val<bool>& left, val<bool>& right) {
Expand All @@ -577,7 +529,7 @@ val<bool> inline lAnd(val<bool>& left, val<bool>& right) {
return val<bool> {tc};
}
#endif
return left.value && right.value;
return getRawValue(left) && getRawValue(right);
}

val<bool> inline lNot(val<bool>& arg) {
Expand All @@ -587,7 +539,7 @@ val<bool> inline lNot(val<bool>& arg) {
return val<bool> {tc};
}
#endif
return !arg.value;
return !getRawValue(arg);
}
} // namespace details

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ void BCLoweringProvider::LoweringContext::process(const std::unique_ptr<ir::Oper
case ir::Operation::OperationType::ConstPtrOp: {
auto constPtr = as<ir::ConstPtrOperation>(opt);
auto defaultRegister = registerProvider.allocRegister();
defaultRegisterFile[defaultRegister] = (int64_t)constPtr->getValue();
defaultRegisterFile[defaultRegister] = (int64_t) constPtr->getValue();

auto targetRegister = registerProvider.allocRegister();
frame.setValue(constPtr->getIdentifier(), targetRegister);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,12 @@ void MLIRLoweringProvider::generateMLIR(ir::ConstIntOperation* constIntOp, Value
}
}

void MLIRLoweringProvider::generateMLIR(ir::ConstPtrOperation* , ValueFrame& ) {
//builder->create<mlir::LLVM::C>(getNameLoc("location"), mlir::LLVM::LLVMPointerType, constPtrOperation->getValue());

//frame.setValue(constPtrOperation->getIdentifier(),
// getConstInt("ConstantOp", constIntOp->getStamp(), constIntOp->getValue()));
void MLIRLoweringProvider::generateMLIR(ir::ConstPtrOperation*, ValueFrame&) {
// builder->create<mlir::LLVM::C>(getNameLoc("location"), mlir::LLVM::LLVMPointerType,
// constPtrOperation->getValue());

// frame.setValue(constPtrOperation->getIdentifier(),
// getConstInt("ConstantOp", constIntOp->getStamp(), constIntOp->getValue()));
}

void MLIRLoweringProvider::generateMLIR(ir::ConstFloatOperation* constFloatOp, ValueFrame& frame) {
Expand Down

0 comments on commit cdc2caa

Please sign in to comment.