MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
util.h File Reference
#include <optional>
#include <queue>
#include <stack>
#include <type_traits>
#include <absl/container/flat_hash_map.h>
#include <absl/container/flat_hash_set.h>
#include <absl/container/node_hash_map.h>
#include <absl/container/node_hash_set.h>
#include <fe/assert.h>
#include "mim/util/hash.h"
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mim::unique_stack< Set >
 
class  mim::unique_queue< Set >
 
struct  mim::GIDHash< T >
 
struct  mim::GIDEq< T >
 
struct  mim::GIDLt< T >
 

Namespaces

namespace  mim
 

Typedefs

GID
template<class K , class V >
using mim::GIDMap = absl::flat_hash_map<K, V, GIDHash<K>, GIDEq<K>>
 
template<class K >
using mim::GIDSet = absl::flat_hash_set<K, GIDHash<K>, GIDEq<K>>
 
template<class K , class V >
using mim::GIDNodeMap = absl::node_hash_map<K, V, GIDHash<K>, GIDEq<K>>
 
template<class K >
using mim::GIDNodeSet = absl::node_hash_set<K, GIDHash<K>, GIDEq<K>>
 

Functions

Utility Functions
template<class This , class T >
T & mim::lazy_init (const This *self, std::unique_ptr< T > &ptr)
 
template<class D , class S >
mim::bitcast (const S &src)
 A bitcast from src of type S to D.
 
template<class T >
bool mim::get_sign (T val)
 
u64 mim::pad (u64 offset, u64 align)
 
Algorithms
template<class I , class T , class Cmp >
mim::binary_find (I begin, I end, T val, Cmp cmp)
 
std::string_view mim::subview (std::string_view s, size_t i, size_t n=std::string_view::npos)
 Like std::string::substr, but works on std::string_view instead.
 
void mim::find_and_replace (std::string &str, std::string_view what, std::string_view repl)
 Replaces all occurrences of what with repl.
 
Helpers for Containers
template<class S >
auto mim::pop (S &s) -> decltype(s.top(), typename S::value_type())
 
template<class Q >
auto mim::pop (Q &q) -> decltype(q.front(), typename Q::value_type())
 
template<class C , class K >
auto mim::lookup (const C &container, const K &key)
 Yields pointer to element (or the element itself if it is already a pointer), if found and nullptr otherwise.
 
template<class C , class... Args>
auto mim::assert_emplace (C &container, Args &&... args)
 Invokes emplace on container, asserts that insertion actually happened, and returns the iterator.