Commit bca915e6 authored by Marius Wachtler's avatar Marius Wachtler

Define i1 as int64 and rename it to llvm_compat_bool

because when calling a function with return type BOOL we currently expect it to return a i64.
This got triggered by the inliner
parent 67360572
......@@ -42,7 +42,7 @@ calliter_traverse(calliterobject *it, visitproc visit, void *arg)
}
// Pyston change: extract most of the body of calliter_iternext here
// so we can use it from both calliter_iternext and calliter_hasnext
// so we can use it from both calliter_iternext and calliterHasnextUnboxed
PyObject *
calliter_next(calliterobject *it)
{
......
......@@ -804,10 +804,9 @@ PyObject* slot_tp_iter(PyObject* self) noexcept {
return call_method(self, "next", &next_str, "()");
}
static bool slotTppHasnext(PyObject* self) {
static llvm_compat_bool slotTppHasnext(PyObject* self) {
STAT_TIMER(t0, "us_timer_slot_tpphasnext", SLOT_AVOIDABILITY(self));
static PyObject* hasnext_str;
Box* r = self->hasnextOrNullIC();
assert(r);
return r->nonzeroIC();
......
......@@ -81,7 +81,6 @@ bool ENABLE_JIT_OBJECT_CACHE = 1 && _GLOBAL_ENABLE;
bool LAZY_SCOPING_ANALYSIS = 1;
bool ENABLE_FRAME_INTROSPECTION = 1;
bool BOOLS_AS_I64 = ENABLE_FRAME_INTROSPECTION;
extern "C" {
int Py_FrozenFlag = 1;
......
......@@ -47,7 +47,7 @@ extern bool ENABLE_ICS, ENABLE_ICGENERICS, ENABLE_ICGETITEMS, ENABLE_ICSETITEMS,
LAZY_SCOPING_ANALYSIS;
// Due to a temporary LLVM limitation, represent bools as i64's instead of i1's.
extern bool BOOLS_AS_I64;
#define BOOLS_AS_I64 1
#define ENABLE_SAMPLING_PROFILER 0
}
......
......@@ -514,7 +514,11 @@ CompiledFunction* compileFunction(FunctionMetadata* f, FunctionSpecialization* s
ExceptionStyle forced_exception_style = CXX);
EffortLevel initialEffort();
typedef bool i1;
#if BOOLS_AS_I64
typedef int64_t llvm_compat_bool;
#else
typedef bool llvm_compat_bool;
#endif
typedef int64_t i64;
const char* getNameOfClass(BoxedClass* cls);
......
......@@ -49,7 +49,7 @@ Box* dictIterValues(Box* self);
Box* dictIterItems(Box* self);
Box* dictIterIter(Box* self);
Box* dictIterHasnext(Box* self);
i1 dictIterHasnextUnboxed(Box* self);
llvm_compat_bool dictIterHasnextUnboxed(Box* self);
Box* dictiter_next(Box* self) noexcept;
Box* dictIterNext(Box* self);
......
......@@ -289,7 +289,7 @@ template <ExceptionStyle S> static Box* generatorNext(Box* s) noexcept(S == CAPI
return generatorSend<S>(s, None);
}
i1 generatorHasnextUnboxed(Box* s) {
llvm_compat_bool generatorHasnextUnboxed(Box* s) {
assert(s->cls == generator_cls);
BoxedGenerator* self = static_cast<BoxedGenerator*>(s);
......
......@@ -49,7 +49,7 @@ Box* dictIterIter(Box* s) {
return s;
}
i1 dictIterHasnextUnboxed(Box* s) {
llvm_compat_bool dictIterHasnextUnboxed(Box* s) {
assert(s->cls == dict_iterator_cls);
BoxedDictIterator* self = static_cast<BoxedDictIterator*>(s);
......
......@@ -50,7 +50,7 @@ Box* listiterHasnext(Box* s) {
return boxBool(ans);
}
i1 listiterHasnextUnboxed(Box* s) {
llvm_compat_bool listiterHasnextUnboxed(Box* s) {
assert(s->cls == list_iterator_cls);
BoxedListIterator* self = static_cast<BoxedListIterator*>(s);
......@@ -95,7 +95,7 @@ Box* listreviterHasnext(Box* s) {
return boxBool(self->pos >= 0);
}
i1 listreviterHasnextUnboxed(Box* s) {
llvm_compat_bool listreviterHasnextUnboxed(Box* s) {
assert(s->cls == list_reverse_iterator_cls);
BoxedListIterator* self = static_cast<BoxedListIterator*>(s);
......
......@@ -36,7 +36,7 @@ Box* tupleiterHasnext(Box* s) {
return boxBool(tupleiterHasnextUnboxed(s));
}
i1 tupleiterHasnextUnboxed(Box* s) {
llvm_compat_bool tupleiterHasnextUnboxed(Box* s) {
assert(s->cls == tuple_iterator_cls);
BoxedTupleIterator* self = static_cast<BoxedTupleIterator*>(s);
......
......@@ -87,7 +87,7 @@ public:
DEFAULT_CLASS(xrange_iterator_cls);
static bool xrangeIteratorHasnextUnboxed(Box* s) __attribute__((visibility("default"))) {
static llvm_compat_bool xrangeIteratorHasnextUnboxed(Box* s) __attribute__((visibility("default"))) {
assert(s->cls == xrange_iterator_cls);
BoxedXrangeIterator* self = static_cast<BoxedXrangeIterator*>(s);
......
......@@ -397,31 +397,6 @@ extern "C" Box* mul_i64_i64(i64 lhs, i64 rhs) {
return longMul(boxLong(lhs), boxLong(rhs));
}
extern "C" i1 eq_i64_i64(i64 lhs, i64 rhs) {
return lhs == rhs;
}
extern "C" i1 ne_i64_i64(i64 lhs, i64 rhs) {
return lhs != rhs;
}
extern "C" i1 lt_i64_i64(i64 lhs, i64 rhs) {
return lhs < rhs;
}
extern "C" i1 le_i64_i64(i64 lhs, i64 rhs) {
return lhs <= rhs;
}
extern "C" i1 gt_i64_i64(i64 lhs, i64 rhs) {
return lhs > rhs;
}
extern "C" i1 ge_i64_i64(i64 lhs, i64 rhs) {
return lhs >= rhs;
}
extern "C" Box* intAddInt(BoxedInt* lhs, BoxedInt* rhs) {
assert(PyInt_Check(lhs));
assert(PyInt_Check(rhs));
......
......@@ -34,12 +34,6 @@ extern "C" Box* add_i64_i64(i64 lhs, i64 rhs);
extern "C" Box* sub_i64_i64(i64 lhs, i64 rhs);
extern "C" Box* pow_i64_i64(i64 lhs, i64 rhs, Box* mod = None);
extern "C" Box* mul_i64_i64(i64 lhs, i64 rhs);
extern "C" i1 eq_i64_i64(i64 lhs, i64 rhs);
extern "C" i1 ne_i64_i64(i64 lhs, i64 rhs);
extern "C" i1 lt_i64_i64(i64 lhs, i64 rhs);
extern "C" i1 le_i64_i64(i64 lhs, i64 rhs);
extern "C" i1 gt_i64_i64(i64 lhs, i64 rhs);
extern "C" i1 ge_i64_i64(i64 lhs, i64 rhs);
extern "C" Box* intAdd(BoxedInt* lhs, Box* rhs);
extern "C" Box* intAnd(BoxedInt* lhs, Box* rhs);
extern "C" Box* intDiv(BoxedInt* lhs, Box* rhs);
......
......@@ -70,7 +70,7 @@ Box* seqiterHasnext(Box* s) {
return rtn;
}
bool seqiterHasnextUnboxed(Box* s) {
llvm_compat_bool seqiterHasnextUnboxed(Box* s) {
return unboxBool(seqiterHasnext(s));
}
......@@ -151,7 +151,7 @@ void BoxedIterWrapper::gcHandler(GCVisitor* v, Box* b) {
v->visit(&iw->next);
}
bool iterwrapperHasnextUnboxed(Box* s) {
llvm_compat_bool iterwrapperHasnextUnboxed(Box* s) {
RELEASE_ASSERT(s->cls == iterwrapper_cls, "");
BoxedIterWrapper* self = static_cast<BoxedIterWrapper*>(s);
......@@ -196,7 +196,7 @@ extern "C" PyObject* PySeqIter_New(PyObject* seq) noexcept {
}
}
bool calliter_hasnext(Box* b) {
llvm_compat_bool calliterHasnextUnboxed(Box* b) {
calliterobject* it = (calliterobject*)b;
if (!it->it_nextvalue) {
it->it_nextvalue = calliter_next(it);
......
......@@ -55,7 +55,7 @@ public:
static void gcHandler(GCVisitor* v, Box* b);
};
bool calliter_hasnext(Box* b);
llvm_compat_bool calliterHasnextUnboxed(Box* b);
void setupIter();
}
......
......@@ -36,12 +36,12 @@ public:
Box* listIter(Box* self) noexcept;
Box* listIterIter(Box* self);
Box* listiterHasnext(Box* self);
i1 listiterHasnextUnboxed(Box* self);
llvm_compat_bool listiterHasnextUnboxed(Box* self);
template <ExceptionStyle S> Box* listiterNext(Box* self) noexcept(S == CAPI);
Box* listiter_next(Box* s) noexcept;
Box* listReversed(Box* self);
Box* listreviterHasnext(Box* self);
i1 listreviterHasnextUnboxed(Box* self);
llvm_compat_bool listreviterHasnextUnboxed(Box* self);
Box* listreviterNext(Box* self);
Box* listreviter_next(Box* s) noexcept;
void listSort(BoxedList* self, Box* cmp, Box* key, Box* reverse);
......
......@@ -2361,7 +2361,7 @@ public:
DEFAULT_CLASS(str_iterator_cls);
static bool hasnextUnboxed(BoxedStringIterator* self) {
static llvm_compat_bool hasnextUnboxed(BoxedStringIterator* self) {
assert(self->cls == str_iterator_cls);
return self->it != self->end;
}
......
......@@ -35,7 +35,7 @@ public:
Box* tupleIter(Box* self) noexcept;
Box* tupleIterIter(Box* self);
Box* tupleiterHasnext(Box* self);
i1 tupleiterHasnextUnboxed(Box* self);
llvm_compat_bool tupleiterHasnextUnboxed(Box* self);
Box* tupleiter_next(Box* self) noexcept;
Box* tupleiterNext(Box* self);
}
......
......@@ -4089,7 +4089,7 @@ void setupRuntime() {
PyType_Ready(&PyByteArrayIter_Type);
PyType_Ready(&PyCapsule_Type);
PyCallIter_Type.tpp_hasnext = calliter_hasnext;
PyCallIter_Type.tpp_hasnext = calliterHasnextUnboxed;
PyType_Ready(&PyCallIter_Type);
PyType_Ready(&PyCObject_Type);
......
......@@ -257,7 +257,7 @@ public:
bool has_subclasscheck;
bool has_getattribute;
typedef bool (*pyston_inquiry)(Box*);
typedef llvm_compat_bool (*pyston_inquiry)(Box*);
// tpp_descr_get is currently just a cache only for the use of tp_descr_get, and shouldn't
// be called or examined by clients:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment