-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[type] Add basic implementations of VectorType and PointerType (#1948)
- Loading branch information
1 parent
2a71e2a
commit dcd5d7d
Showing
11 changed files
with
239 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "taichi/ir/type.h" | ||
#include "taichi/program/program.h" | ||
|
||
TLANG_NAMESPACE_BEGIN | ||
|
||
// Note: these primitive types should never be freed. They are supposed to live | ||
// together with the process. This is a temporary solution. Later we should | ||
// manage its ownership more systematically. | ||
|
||
// This part doesn't look good, but we will remove it soon anyway. | ||
#define PER_TYPE(x) \ | ||
DataType PrimitiveType::x = \ | ||
DataType(Program::get_type_factory().get_primitive_type( \ | ||
PrimitiveType::primitive_type::x)); | ||
|
||
#include "taichi/inc/data_type.inc.h" | ||
#undef PER_TYPE | ||
|
||
DataType::DataType() : ptr_(PrimitiveType::unknown.ptr_) { | ||
} | ||
|
||
DataType PrimitiveType::get(PrimitiveType::primitive_type t) { | ||
if (false) { | ||
} | ||
#define PER_TYPE(x) else if (t == primitive_type::x) return PrimitiveType::x; | ||
#include "taichi/inc/data_type.inc.h" | ||
#undef PER_TYPE | ||
else { | ||
TI_NOT_IMPLEMENTED | ||
} | ||
} | ||
|
||
std::size_t DataType::hash() const { | ||
if (auto primitive = dynamic_cast<const PrimitiveType *>(ptr_)) { | ||
return (std::size_t)primitive->type; | ||
} else { | ||
TI_NOT_IMPLEMENTED | ||
} | ||
} | ||
|
||
std::string PrimitiveType::to_string() const { | ||
return data_type_name(DataType(this)); | ||
} | ||
|
||
TLANG_NAMESPACE_END |
Oops, something went wrong.